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

**URL:** <https://developer.sailpoint.com/discuss/t/using-oldvalue-to-compare-the-old-and-actual-value-of-an-identity-attribute/4316>\
**Category:** SHF Discussion and Questions\
**Created:** [May 20, 2022, 8:57am UTC](https://developer.sailpoint.com/discuss/t/using-oldvalue-to-compare-the-old-and-actual-value-of-an-identity-attribute/4316 "2022-05-20T08:57:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosquinClv](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@JosquinClv](https://developer.sailpoint.com/discuss/u/JosquinClv)\
**Post date:** [May 20, 2022, 8:57am UTC](https://developer.sailpoint.com/discuss/t/using-oldvalue-to-compare-the-old-and-actual-value-of-an-identity-attribute/4316/1 "2022-05-20T08:57:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tyler\_mairose](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/tyler_mairose/32/30112_2.png) [@tyler\_mairose](https://developer.sailpoint.com/discuss/u/tyler_mairose)\
**Post date:** [May 23, 2022, 7:59pm UTC](https://developer.sailpoint.com/discuss/t/using-oldvalue-to-compare-the-old-and-actual-value-of-an-identity-attribute/4316/2 "2022-05-23T19:59:46Z")

</div>

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:

```auto
{
    "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"
}

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:23pm UTC](https://developer.sailpoint.com/discuss/t/using-oldvalue-to-compare-the-old-and-actual-value-of-an-identity-attribute/4316/3 "2023-07-19T14:23:05Z")

</div>


