Transform Assistance - Lifecycle State & Handling Nulls

Hello All!

We’re early in our identity journey and I’m trying to return either “Inactive” or “Active” for my lifecycle states. I’m invoking the dateCompare function against today’s date and an employees termination date.

I encounter an error when the employee does not have a termination date - in other words still active, however my NULL handing isn’t working as expected:

{
"name": "Lifecycle-State-Dates",
"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": "accountAttribute",
"attributes": {
"sourceName": "OMERS WORKDAY",
"attributeName": "TERMINATION_DATE"
}
},
"inputFormat": "MM/dd/yyyy",
"outputFormat": "ISO8601"
}
},
"operator": "gte",
"positiveCondition": "true",
"negativeCondition": "false"
}
},
"value": "#if($inPast=='true')Inactive#elseif($inPast=='false')Active#{else}Inactive#end"
},
"internal": false
}

Looking for some guidance here, whether to leverage the firstValid function (specifically where) to address active employees who do not have a termination date.

@nyeung Can you try the below code. Make sure you set the static termination date as per your condition.

{
    "attributes": {
        "inPast": {
            "attributes": {
                "firstDate": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "expression": "now"
                            },
                            "type": "dateMath"
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "negativeCondition": "false",
                "operator": "gte",
                "positiveCondition": "true",
                "secondDate": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "attributeName": "TERMINATION_DATE",
                                            "sourceName": "OMERS WORKDAY"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "01/01/1900"
                                ]
                            },
                            "type": "firstValid"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                }
            },
            "type": "dateCompare"
        },
        "value": "#if($inPast=='true')Inactive#elseif($inPast=='false')Active#{else}Inactive#end"
    },
    "internal": false,
    "name": "Lifecycle-State-Dates",
    "type": "static"
}

Thanks

1 Like

Hi Shantha,

Thank you for looking into this!

Initially the code returned InActive for every employee. However, once I updated the static termination date to a future date beyond ‘now’, this returned the expected result.

If you want to add dateMath instead of the static field, use the below code
{ "attributes": { "expression": "now+1d" }, "type": "dateMath" }