Issue with termination trigger transform

Hello,
I am writing a transform to set the value true or false based on the Termination date and Termination category account attribute from workday.

I am getting an exception while calculating the value for this identity attribute.

Exception:
There was an exception while calculating the value for this attribute. Error during transformation for attribute: workdayemailterm (Transform ID: Termination Trigger based on category workday test) Cause: Text ‘’ could not be parsed at index 0

Transform:

{
    "id": "45ce75f5-ec6a-432d-a7e3-407d1eb6b633",
    "name": "Termination Trigger based on category workday test",
    "type": "static",
    "attributes": {
        "terminationCategory": {
            "attributes": {
                "sourceName": "Workday Sandbox",
                "attributeName": "TERMINATION_CATEGORY__c"
            },
            "type": "accountAttribute"
        },
        "dateCompare": {
            "attributes": {
                "firstDate": {
                    "attributes": {
                        "addition": {
                            "attributes": {
                                "sourceName": "Workday Sandbox",
                                "attributeName": "TERMINATION_DATE"
                            },
                            "type": "accountAttribute"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "secondDate": "now",
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            },
            "type": "dateCompare"
        },
        "value": "#if($dateCompare == 'true' && $terminationCategory == 'Voluntary')true#{else}false #end"
    },
    "internal": false
}

I am not entirely sure why it is failing. Is it not able to fetch the account attribute from workday sandbox source?

Ah I see why it is giving the error. Looks like the Termination date field is usually empty until someone resigns or terminated.

Wondering if there a way to better way to do this.

You can use firstValid transform to handle this scenario with future termination date when it is empty or null. Sample below,

{
    "id": "45ce75f5-ec6a-432d-a7e3-407d1eb6b633",
    "name": "Termination Trigger based on category workday test",
    "type": "static",
    "attributes": {
        "terminationCategory": {
            "attributes": {
                "sourceName": "Workday Sandbox",
                "attributeName": "TERMINATION_CATEGORY__c"
            },
            "type": "accountAttribute"
        },
        "dateCompare": {
            "attributes": {
                "firstDate": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "values": [
                                    {
                                        "attributes": {
                                            "attributeName": "TERMINATION_DATE",
                                            "sourceName": "Workday Sandbox"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "12/31/9999"
                                ],
                                "ignoreErrors": "true"
                            },
                            "type": "firstValid"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "secondDate": "now",
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            },
            "type": "dateCompare"
        },
        "value": "#if($dateCompare == 'true' && $terminationCategory == 'Voluntary')true#{else}false #end"
    },
    "internal": false
}
1 Like

if either of the attributes that you are parsing into the “value”: “…” are null ($dateCompare or $terminationCategory), then the expression will fail. Wrap each one in firstValid transforms and set a default expression.

2 Likes

This is missing the firstValid on the TERMINATION_CATEGORY__c attribute.

2 Likes

Thank you so much! if attribute “Termination_Category__c” is empty, will it still work?

Ah so it needs firstValid for both “TERMINATION_CATEGORY__c” and “TERMINATION_DATE”

1 Like

No it will not work, you need to add firstValid transform for both.

yep. i would suggest marking @phil_awlings’s comment as the correct solution, as he was the first to correctly recommend using firstValid transforms on both attributes.

1 Like

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