Issue with LifecycleState Transform

Hi,

I am writing a lifecycle state transform and getting below error:
There was an exception while calculating the value for this attribute. java.time.format.DateTimeParseException: Text ‘none’ could not be parsed at index 0

Transform is as below:

{

"name": "Determine Workday LCS",
"type": "static",
"attributes": {
    "requiresPeriodicRefresh": "true",
    "activestate": {
        "attributes": {
            "firstDate": "now",
            "secondDate": {
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "HIREDATE",
                            "sourceName": "WorkDay_Test"
                        }
                    },
                    "inputFormat": "MM/dd/yyyy",
                    "outputFormat": "ISO8601"
                },
                "type": "dateFormat"
            },
            "operator": "GTE",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "prehire": {
        "attributes": {
            "firstDate": {
                "attributes": {
                    "expression": "now+45d/d",
                    "roundUp": false
                },
                "type": "dateMath"
            },
            "secondDate": {
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "HIREDATE",
                            "sourceName": "WorkDay_Test"
                        }
                    },
                    "inputFormat": "MM/dd/yyyy",
                    "outputFormat": "ISO8601"
                },
                "type": "dateFormat"
            },
            "operator": "GTE",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "onleave": {
        "attributes": {
            "values": [
                {
                    "attributes": {
                        "attributeName": "ON_LEAVE",
                        "sourceName": "WorkDay_Test"
                    },
                    "type": "accountAttribute"
                },
                {
                    "attributes": {
                        "value": "none"
                    },
                    "type": "static"
                }
            ]
        },
        "type": "firstValid"
    },
    "inactivestate": {
        "attributes": {
            "firstDate": "now",
            "secondDate": {
                "type": "firstValid",
                "attributes": {
                    "values": [
                        {
                            "attributes": {
                                "input": {
                                    "type": "accountAttribute",
                                    "attributes": {
                                        "attributeName": "TERMINATION_DATE",
                                        "sourceName": "WorkDay_Test"
                                    }
                                },
                                "inputFormat": "MM/dd/yyyy",
                                "outputFormat": "ISO8601"
                            },
                            "type": "dateFormat"
                        },
                        {
                            "attributes": {
                                "value": "none"
                            },
                            "type": "static"
                        }
                    ]
                    
                }
            },
            "operator": "GT",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "value": "#if(($inactivestate == 'no' || $inactivestate == 'none') && $activestate == 'yes' && ($onleave == 'none' || $onleave == '0'))active#elseif($activestate == 'no' && $prehire == 'yes' && $onleave != '1')prehire#elseif($onleave == '1')leaveOfAbsence#elseif($inactivestate == 'yes')inactive#{else}UNKNOWN#end"
}

}

The error is coming from inactive tag but not sure the location of specific error as it is not able to pick ‘none’ for the inactive tag.

Hi @Mahak,

The static value "none" in your firstValid transform which provides input to the secondDate of your dateCompare transform is not valid. It is trying to evaluate the string "none" as a date.

Assuming that you would want the inactivestate variable to result in the negativeCondition if the attribute TERMINATION_DATE is missing on the account. You can put "now" as your second result to return in the firstValid. I have modified your transform below for my proposed solution.

{
    "name": "Determine Workday LCS",
    "type": "static",
    "attributes": {
        "requiresPeriodicRefresh": "true",
        "activestate": {
            "attributes": {
                "firstDate": "now",
                "secondDate": {
                    "attributes": {
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "attributeName": "HIREDATE",
                                "sourceName": "WorkDay_Test"
                            }
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "operator": "GTE",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "prehire": {
            "attributes": {
                "firstDate": {
                    "attributes": {
                        "expression": "now+45d/d",
                        "roundUp": false
                    },
                    "type": "dateMath"
                },
                "secondDate": {
                    "attributes": {
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "attributeName": "HIREDATE",
                                "sourceName": "WorkDay_Test"
                            }
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                },
                "operator": "GTE",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "onleave": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "ON_LEAVE",
                            "sourceName": "WorkDay_Test"
                        },
                        "type": "accountAttribute"
                    },
                    {
                        "attributes": {
                            "value": "none"
                        },
                        "type": "static"
                    }
                ]
            },
            "type": "firstValid"
        },
        "inactivestate": {
            "attributes": {
                "firstDate": "now",
                "secondDate": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "TERMINATION_DATE",
                                            "sourceName": "WorkDay_Test"
                                        }
                                    },
                                    "inputFormat": "MM/dd/yyyy",
                                    "outputFormat": "ISO8601"
                                },
                                "type": "dateFormat"
                            },
                            "now"
                        ]
                    }
                },
                "operator": "GT",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "value": "#if(($inactivestate == 'no') && $activestate == 'yes' && ($onleave == 'none' || $onleave == '0'))active#elseif($activestate == 'no' && $prehire == 'yes' && $onleave != '1')prehire#elseif($onleave == '1')leaveOfAbsence#elseif($inactivestate == 'yes')inactive#{else}UNKNOWN#end"
    }
}