# oldValue update

**URL:** <https://developer.sailpoint.com/discuss/t/oldvalue-update/13669>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, sailpoint-identity-security\
**Created:** [June 30, 2023, 1:43am UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669 "2023-06-30T01:43:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsierra](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@gsierra](https://developer.sailpoint.com/discuss/u/gsierra)\
**Post date:** [June 30, 2023, 1:43am UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/1 "2023-06-30T01:43:13Z")

</div>

Hi! I’ve been trying to get the last previous value of an attribute. So, if there was a modification from values “X01” to “X02” and finally “X03”, i always need to read the n-1 previous value, that would be “X02” here.

I tried using this transform, but i always get the first value there was in this attribute, for example X01. Code attached. Any idea? Thanks!

```auto
{
  "attributes": {
    "values": [
      "$oldValue",
      {
        "attributes": {
          "sourceName": "Mock-SAIP",
          "attributeName": "storeID"
        },
        "type": "accountAttribute"
      }
    ]
  },
  "type": "firstValid",
  "name": "oldValue firstValid"
}

```

---

<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:** [August 29, 2023, 1:44am UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/2 "2023-08-29T01:44:03Z")

</div>

Closed on August 29, 2023, 1:44am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

---

<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:** [August 25, 2025, 5:13pm UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/3 "2025-08-25T17:13:05Z")

</div>

Opened on August 25, 2025, 5:13pm UTC



---

<div class="post-metadata">

**Author:** ![Gokul\_Ananth\_M\_08](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gokul_ananth_m_08/32/43615_2.png) [@Gokul\_Ananth\_M\_08](https://developer.sailpoint.com/discuss/u/Gokul_Ananth_M_08)\
**Post date:** [August 25, 2025, 7:00pm UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/4 "2025-08-25T19:00:35Z")

</div>

Hi @gsierra ,

Try this step-by-step,

See whether the oldValue prints.

```json
{
  "type": "static",
  "attributes": {
    "value": "$oldValue"
  }
}

```

If this is populated, check the below:

```json
{
  "type": "firstValid",
  "attributes": {
    "values": [
      "$oldValue",
      "no oldValue"
    ]
  }
}

```

If these works, then there might be some issue in the `accountAttribute` part.

---

<div class="post-metadata">

**Author:** ![Gokul\_Ananth\_M\_08](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gokul_ananth_m_08/32/43615_2.png) [@Gokul\_Ananth\_M\_08](https://developer.sailpoint.com/discuss/u/Gokul_Ananth_M_08)\
**Post date:** [August 25, 2025, 7:05pm UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/5 "2025-08-25T19:05:16Z")

</div>

```json
"attributes": {
    "ignoreErrors": "true",
    "values": [
        "$oldValue",
        {
            "attributes": {
                "attributeName": "abcd",
                "sourceName": "test"
            },
            "type": "accountAttribute"
        },
        "no value"
    ]
},
"type": "firstValid"

```

Try this.

The transform is set up to do the following:

1. First, it tries to return $oldValue, which represents the attribute’s previous value.

2. If $oldValue is null, it then attempts to retrieve the “abcd” attribute from the “test” source.

3. If both of the above are null, it returns the static value “no value”.

---

<div class="post-metadata">

**Author:** ![bmbuntum](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bmbuntum](https://developer.sailpoint.com/discuss/u/bmbuntum)\
**Post date:** [August 25, 2025, 8:18pm UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/6 "2025-08-25T20:18:00Z")

</div>

Issue here is it $oldValue will always be the first none null value and will never be updated after that. So in the case where source attribute values change from “X01” to “X02” and finally “X03”, the $oldValue will forever be “X01” (for this transform)

---

<div class="post-metadata">

**Author:** ![suresh4iam](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/suresh4iam/32/29513_2.png) [@suresh4iam](https://developer.sailpoint.com/discuss/u/suresh4iam)\
**Post date:** [August 25, 2025, 9:15pm UTC](https://developer.sailpoint.com/discuss/t/oldvalue-update/13669/7 "2025-08-25T21:15:47Z")

</div>

You can try the below transform which returns old value when account attribute is not empty/null and both new and old values are not equal, otherwise it returns new value.

```auto
  {
        "name": "Old Value Test",
        "type": "static",
        "attributes": {
            "currentValue": {
                "attributes": {
                    "ignoreErrors": "true",
                    "values": [
                        {
                            "attributes": {
                                "attributeName": "storeID",
                                "sourceName": "Mock-SAIP"
                            },
                            "type": "accountAttribute"
                        },
                        "none"
                    ]
                },
                "type": "firstValid"
            },
            "previousValue": {
                "attributes": {
                    "ignoreErrors": "true",
                    "values": [
                        {
                            "attributes": {
                                "value": "${oldValue}"
                            },
                            "type": "static"
                        },
                        "none"
                    ]
                },
                "type": "firstValid"
            },
            "value": "#if ($currentValue != 'none' && $currentValue != $previousValue)$previousValue#{else}$currentValue#{end}"
        },
        "internal": false
    }

```
