LCS Issue in the transform

Hello.

Below LCS transform is having issue. Any help?

The requirement is start date less than or equal to today set to active and based on the term date today immediately set to inactive

For start date it showing Active. which looks good
image

End date(termDate) is 4/5/2024 but it is showing Active instead of inactive.

image

{
    
    "name": "test LifecycleState",
    "type": "static",
    "attributes": {
        "requiresPeriodicRefresh": "true",
        "activestate": {
            "attributes": {
                "firstDate": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "Start Date",
                                            "sourceName": "test"
                                        }
                                    },
                                    "inputFormat": "MM/dd/yyyy",
                                    "outputFormat": "ISO8601"
                                },
                                "type": "dateFormat"
                            },
                            "2000-01-01T00:00:00Z"
                        ]
                    }
                },
                "secondDate": "now",
                "operator": "LTE",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "termination": {
            "attributes": {
                "firstDate": "now",
                "secondDate": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "TermDate",
                                            "sourceName": "test"
                                        }
                                    },
                                    "inputFormat": "MM/dd/yyyy",
                                    "outputFormat": "ISO8601"
                                },
                                "type": "dateFormat"
                            },
                            "now"
                        ]
                    }
                },
                "operator": "LTE",
                "positiveCondition": "yes",
                "negativeCondition": "no"
            },
            "type": "dateCompare"
        },
        "value": "#if($activestate == 'yes')Active#elseif($termination == 'yes')inacive#end"
    },
    "internal": false
}

Your transform is basically independently comparing startDate with now and termDate with now, but you never compare termDate with startDate.

Because #if($activestate == ‘yes’)Active
comes before
#elseif($termination == ‘yes’)inacive

you will always return active (assuming startDate is populated).

You either need a check to see if termDate >= startDate or change the operations such that the termination check comes before the active check.

3 Likes