LCS not working for inactive and termination cases

Hi team,
i have a requirement as below.
1.if user startdate is within next 5 days from today (end date can be null or not) - prehire
2.if user startdate is more than 5 days from today (end date can be null or not) – futureprehire
3.user enddate+1 till enddate+7 , user should be in inactive
4.post 7 days from inactive state (enddate), user should be into termination state.

i have a transform, which is failing wither inactive or termination cases. any help is much appreciated. i am copying my transformation here.please help.

{

"name": "LCS",
"type": "static",
"attributes": {
    "requiresPeriodicRefresh": "true",
    "activestate": {
        "attributes": {
            "firstDate": "now",
            "secondDate": {
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "employeeStartDate",
                            "sourceName": ""
                        }
                    },
                    "inputFormat": "dd/MM/yyyy",
                    "outputFormat": "ISO8601"
                },
                "type": "dateFormat"
            },
            "operator": "GTE",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "prehire": {
        "attributes": {
            "firstDate": {
                "attributes": {
                    "expression": "now+5d/d",
                    "roundUp": false
                },
                "type": "dateMath"
            },
            "secondDate": {
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "employeeStartDate",
                            "sourceName": ""
                        }
                    },
                    "inputFormat": "dd/MM/yyyy",
                    "outputFormat": "ISO8601"
                },
                "type": "dateFormat"
            },
            "operator": "GTE",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "futureprehire": {
        "attributes": {
            "firstDate": {
                "attributes": {
                    "expression": "now+5d/d",
                    "roundUp": false
                },
                "type": "dateMath"
            },
            "secondDate": {
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "employeeStartDate",
                            "sourceName": ""
                        }
                    },
                    "inputFormat": "dd/MM/yyyy",
                    "outputFormat": "ISO8601"
                },
                "type": "dateFormat"
            },
            "operator": "LT",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "inactivestate": {
        "attributes": {
            "firstDate": {
                "attributes": {
                    "expression": "now",
                    "roundUp": false
                },
                "type": "dateMath"
            },
            "secondDate": {
                "type": "firstValid",
                "attributes": {
                    "values": [
                        {
                            "attributes": {
                                "expression": "+7d/d",
                                "input": {
                                    "type": "accountAttribute",
                                    "attributes": {
                                        "sourceName": "",
                                        "attributeName": "employeeEndDate"
                                    }
                                },
                                "inputFormat": "dd/MM/yyyy",
                                "outputFormat": "ISO8601"
                            },
                            "type": "dateFormat"
                        },
                        {
                            "attributes": {
                                "expression": "now+999d/d",
                                "roundUp": false
                            },
                            "type": "dateMath"
                        }
                    ],
                    "ignoreErrors": "true"
                }
            },
            "operator": "LT",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "terminated": {
        "attributes": {
            "firstDate": {
                "attributes": {
                    "expression": "now",
                    "roundUp": false
                },
                "type": "dateMath"
            },
            "secondDate": {
                "type": "firstValid",
                "attributes": {
                    "values": [
                        {
                            "attributes": {
                                "expression": "+7d/d",
                                "input": {
                                    "type": "accountAttribute",
                                    "attributes": {
                                        "sourceName": "",
                                        "attributeName": "employeeEndDate"
                                    }
                                },
                                "inputFormat": "dd/MM/yyyy",
                                "outputFormat": "ISO8601"
                            },
                            "type": "dateFormat"
                        },
                        {
                            "attributes": {
                                "expression": "now+999d/d",
                                "roundUp": false
                            },
                            "type": "dateMath"
                        }
                    ]
                }
            },
            "operator": "GT",
            "positiveCondition": "yes",
            "negativeCondition": "no"
        },
        "type": "dateCompare"
    },
    "value": "#if(($inactivestate=='yes')&&($terminated=='no'))inactive#elseif($terminated=='yes')terminated#elseif(($activestate=='yes') && ($inactivestate=='no'))active#elseif(($prehire=='yes')&&($activestate=='no'))prehire#elseif(($prehire=='no')&&($activestate=='no'))futureprehire#{else}UNKNOWN#end"
},
"internal": false

}

Thanks
Stella

Hi @stellaantony, I noticed that for both inactiveState and terminated cases, while you have the expression to add days to the employeeEndDate account attribute, but there is no dateMath operation type specified in your script.

I have extracted the secondDate first item from the first valid case (inactiveState) in your script and tweaked a bit based on your requirements. It should be the similar tweak for both inactive and terminated states.

// for inactive state - secondDate firstValid 1st item
{
    "attributes": {
        "expression": "+7d/d",
        "input": {
            "type": "dateFormat",
            "attributes": {
                "inputFormat": "dd/MM/yyyy",
                "outputFormat": "ISO8601",
                "input": {
                    "type": "accountAttribute",
                    "attributes": {
                        "sourceName": "",
                        "attributeName": "employeeEndDate"
                    }
                }
            }
        }
    },
    "type": "dateMath"
}

You can try this and hope this helps.

1 Like

Hi @sjoyee ,
Thank you so much, it works. was digging this for last 2 days. thanks much for the assistance.

Thanks
Stella

1 Like

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