Template exception when using the oldValue on identity creation

Hello,
I’m trying to create a transform to handle the cloudLifecycleState attribute calculation.
It should be set to prehire when the identity in created. The date calculation are working as I tested the but the null check over the oldValue not and the oldValue is triggering an exception also if i just want to print it out.
This is the rule:

{
    "name": "TWT - Calculate Lifecycle State",
    "type": "static",
    "attributes": {
        "inPast": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "dateMath",
                            "attributes": {
                                "expression": "now"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "static",
                            "attributes": {
                                "value": "$identity.getStringAttribute('startDate').substring(0,10)"
                            }
                        },
                        "inputFormat": "YYYY-MM-dd",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "gte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "inLessThan10Day": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "static",
                            "attributes": {
                                "value": "$identity.getStringAttribute('startDate').substring(0,10)"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "dateMath",
                            "attributes": {
                                "expression": "now-10d"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "gte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "inFuture": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "static",
                            "attributes": {
                                "value": "$identity.getStringAttribute('startDate').substring(0,10)"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "dateMath",
                            "attributes": {
                                "expression": "now+10d"
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "gte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "value": "#if( $oldValue == '' || $inFuture == 'true')prehire#elseif($oldValue == 'prehire' && $inLessThan10Day == 'true')joiner#elseif($oldValue == 'joiner' && $inPast == 'true')active#{else}$oldValue#end"
    },
    "internal": false
}

Can someone help me in checking for previous null value?
Thanks

Escape it with a “firstValid” by adding in something like the following:

		"oldValueEscaped":{
			"attributes":{
				"ignoreErrors":"true",
				"values":[
					"$oldValue",
					"NOTSET"
			},
			"type":"firstValid"
			
		},

Then update your “value” accordingly:

"value": "#if( $oldValueEscaped == 'NOTSET' || $inFuture == 'true')prehire#elseif($oldValueEscaped == 'prehire' && $inLessThan10Day == 'true')joiner#elseif($oldValueEscaped == 'joiner' && $inPast == 'true')active#{else}$oldValue#end"

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