Using $oldValue to compare the old and actual value of an identity attribute

Hello Developer community,

I am trying to use the OldValue attribute to make a comparision between its old value and its actual value after an aggregation occures ( here I am using a delimited file for my tests)

The idea:
A user got a “AnteriorFonction” attribute updated, like for a job mobility.
The attribute is compared to its old value and if the value changed I want to set a new static value for this attribute. The other way I want to keep the last value of this identity attribute.

Here is my transform which cannot calculate the value of my identity attribute :
{

"attributes": {

    "expression": "$fonction eq $oldfonction",

    "positiveCondition": "$actualValue",

    "negativeCondition": "$newValue",

    "fonction": {

        "attributes": {

            "sourceName": "test",

            "attributeName": "AnteriorFonction"

        },

        "type": "identityAttribute"

    },

    "oldfonction": {

        "attributes": {

            "input": {

                "attributes": {

                    "ignoreErrors": "true",

                    "values": [

                        "$oldValue",

                        {

                            "attributes": {

                                "attributeName": "AnteriorFonction",

                                "sourceName": "test"

                            },

                            "type": "identityAttribute"

                        },

                        "none"

                    ]

                },

                "type": "firstValid"

            }

        },

        "type": "lower"

    },

    "newValue": {

        "attributes": {

            "value": "newValue"

        },

        "type": "static"

    },

    "actualValue": {

        "attributes": {

            "attributeName": "AnteriorFonction",

            "sourceName": "test"

        },

        "type": "identityAttribute"

    }

},

"type": "conditional",

"name": "test_oldvalue"

}

With the error : There was an exception while calculating the value for this attribute. java.lang.RuntimeException: Error running identity attribute transform:java.lang.IllegalArgumentException: Value of ‘name’ cannot be null.

Do you have some suggestion ?
Thanks.

Hello @JosquinClv,

You are using identityAttribute instead of accountAttribute every time you pull the AnteriorFonction value from your source. In order to get an account attribute from the source you will want to use accountAttribute as the type. See below:

{
    "attributes": {
        "expression": "$fonction eq $oldfonction",
        "positiveCondition": "$actualValue",
        "negativeCondition": "$newValue",
        "fonction": {
            "attributes": {
                "sourceName": "test",
                "attributeName": "AnteriorFonction"
            },
            "type": "accountAttribute"
        },
        "oldfonction": {
            "attributes": {
                "input": {
                    "attributes": {
                        "ignoreErrors": "true",
                        "values": [
                            "$oldValue",
                            {
                                "attributes": {
                                    "attributeName": "AnteriorFonction",
                                    "sourceName": "test"
                                },
                                "type": "accountAttribute"
                            },
                            "none"
                        ]
                    },
                    "type": "firstValid"
                }
            },
            "type": "lower"
        },
        "newValue": {
            "attributes": {
                "value": "newValue"
            },
            "type": "static"
        },
        "actualValue": {
            "attributes": {
                "attributeName": "AnteriorFonction",
                "sourceName": "test"
            },
            "type": "accountAttribute"
        }
    },
    "type": "conditional",
    "name": "test_oldvalue"
}