How to retain the current date in transform

Hi Team,

I am stuck on one of the transform where I need your assistance. Here we need to calculate the value as null or current date based on below requirement.

if Leaver date has 31.12.9999 then it can have null value means no plan of leaving the organisation but if leaver date has some other valid date other than 31.12.9999 ,then this transform should set current date, but it should not update on daily basis.

Please note : current date should not get changed if it has been calculated today as 26.03.2026 it should not be update tomorrow and so on.

if leaver date == 31.12.9999 then NULL

if leaver date is having some valid date other than 31.12.9999 then it should set current date as 26-03-2026, We have designed something similar to requirement but encountering some rendering error.

Here is my transform which I was using.

{
  "name": "Leaver Notice Date Persistent Transform",
  "type": "static",
  "attributes": {
    "existingValue": {
  "type":"firstValid",
  "attributes": {
  "values": [
  {
      "attributes": {
        "name": "leaverNoticeDate"
      },
    "type": "identityAttribute"
  },
  {
   "attributes":{
      "value" :"NO_VALUE"
    },
    "type":"static"
  }
  ]
  }
    },
    "leaverDate": {
      "type": "identityAttribute",
      "attributes": {
        "name": "terminateddate"
      }
    },
    "currentDate": {
      "type": "dateMath",
      "attributes": {
        "expression": "now",
        "outputFormat": "ISO8601"
      }
    },
    "value": "#if($existingValue && $existingValue != 'NO_VALUE')$existingValue#elseif($leaverDate && $leaverDate != '31.12.9999')$currentDate#else $null#end"
  },
  "internal": false
}

This bit is wrong:

$existingValue && $existingValue != 'NO_VALUE'
and this bit:
$leaverDate && $leaverDate != '31.12.9999'
and this bit:
$null

EDIT: This bit needs to have a firstValid to catch nulls:
"leaverDate": {

And I’m not 100% sure that this is the correct way to get today’s date:
"currentDate": {

This should do it:

{
  "name": "Leaver Notice Date Persistent Transform",
  "type": "trim",
  "attributes": {
    "input": {
      "type": "static",
      "attributes": {
        "existingValue": {
          "type": "firstValid",
          "attributes": {
            "values": [
              {
                "type": "identityAttribute",
                "attributes": {
                  "name": "leaverNoticeDate"
                }
              },
              "NO_VALUE"
            ]
          }
        },
        "leaverDate": {
          "type": "firstValid",
          "attributes": {
            "values": [
              {
                "type": "identityAttribute",
                "attributes": {
                  "name": "terminateddate"
                }
              },
              "NO_VALUE"
            ]
          }
        },
        "currentDate": {
          "type": "dateMath",
          "attributes": {
            "expression": "now",
            "outputFormat": "ISO8601"
          }
        },
        "value": "#if($leaverDate == '31.12.9999') #{elseif}($existingValue != 'NO_VALUE')$existingValue#{else}$currentDate#end"
      }
    }
  }
}

The condition is picking up the last value i.e “#else $null#end”. Can you try putting some other value in else part like

#else ”Test Null” #end” or just

#else #end

Or this:

{
“name”: “Leaver Notice Date Persistent Transform”,
“type”: “static”,
“attributes”: {
“existingValue”: {
“type”:“firstValid”,
“attributes”: {
“values”: [
{
“attributes”: {
“name”: “leaverNoticeDate”
},
“type”: “identityAttribute”
},
{
“attributes”:{
“value” :“NO_VALUE”
},
“type”:“static”
}
]
}
},
“leaverDate”: { “type”:“firstValid”,
“attributes”: {
“values”: [
{
“attributes”: {
“name”: “terminateddate”
},
“type”: “identityAttribute”
},
{
“attributes”:{
“value” :“NO_VALUE”
},
“type”:“static”
}
]
}},
“currentDate”: {
“type”: “dateMath”,
“attributes”: {
“expression”: “now”,
“outputFormat”: “ISO8601”
}
},
“value”: “#if($existingValue && $existingValue != ‘NO_VALUE’)$existingValue#elseif($leaverDate && $leaverDate != ‘NO_VALUE’)$currentDate#else ‘NO_VALUE’#end
},
“internal”: false
}

all 3 should get you a good start

overall, this sounds like a flawed workflow. sailpoint should not be the source of truth for attribute values, it should be passing values it’s received from another source. what you’re looking to do is realistically not possible with transforms, because transforms, by definition, are designed to transform (or manipulate) existing data, not generate it.

i would caution against trying to force this functionality using the above suggestions. even if you are able to make it work, it is very likely that an identity refresh or some other automated mechanism could result in the values being wiped out or reset, causing whatever downstream logic you have depending on this to misfire.

if you’re looking to, for example, sync this value down to Active Directory or something, there are other mechanisms by which you can do this. an AfterModify rule is one way to set a value that doesn’t have to come from a transform/Identity Attribute, but there are other ways as well. but transforms ain’t it, fam.

1 Like

Hi @LearningStar @phil_awlings @lampard08 I am late to the thread but noticed an issue with the transforms shared.
The variable being used for ‘currentDate’ seems to be using an incorrect syntax for the Date Math transform:

It should be something like this instead:

“currentDate”: {

                "type": "dateFormat",

                "attributes": {

                    "inputFormat": "ISO8601",

                    "outputFormat": "dd.MM.yyyy",

                    "input": {

                        "type": "dateMath",

                        "attributes": {

                            "expression": "now/d",

                            "roundUp": false

                        }

                    }

                }

            }

I would suggest to give this a try:

{

"name": "Leaver Notice Date Persistent Transform",

"type": "trim",

"attributes": {

    "input": {

        "type": "static",

        "attributes": {

            "existingValue": {

                "type": "firstValid",

                "attributes": {

                    "values": \[

                        {

                            "type": "identityAttribute",

                            "attributes": {

                                "name": "leaverNoticeDate"

                            }

                        },

                        "NO_VALUE"

                    \]

                }

            },

            "leaverDate": {

                "type": "firstValid",

                "attributes": {

                    "values": \[

                        {

                            "type": "identityAttribute",

                            "attributes": {

                                "name": "terminateddate"

                            }

                        },

                        "NO_VALUE"

                    \]

                }

            },

            "currentDate": {

                "type": "dateFormat",

                "attributes": {

                    "inputFormat": "ISO8601",

                    "outputFormat": "dd.MM.yyyy",

                    "input": {

                        "type": "dateMath",

                        "attributes": {

                            "expression": "now/d",

                            "roundUp": false

                        }

                    }

                }

            },

            "value": "#if($leaverDate == '31.12.9999') #{elseif}($existingValue != 'NO_VALUE')$existingValue#{else}$currentDate#end"

        }

    }

}

}

I guarantee that my syntax works, but thanks for the input