# Transformation for setup lifecycle state

**URL:** <https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, sailpoint-identity-security\
**Created:** [May 24, 2024, 11:42am UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909 "2024-05-24T11:42:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polarao](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Polarao](https://developer.sailpoint.com/discuss/u/Polarao)\
**Post date:** [May 24, 2024, 11:42am UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/1 "2024-05-24T11:42:28Z")

</div>

We have onboarded a new source for contractors called LDAP. We need to set up lifecycle states based on three attributes start date, exit date, and Isexpired date. The condition is that when the exit date is valid and greater than the expiration date, then the lifecycle state should be set to “Is expired.” We have already developed two states: isPreHire and isTerminated. Can you please help me with setting up the Is Expired state?

```auto
"name": "Calculate Lifecycle State - Sandbox",

    "type": "static",

    "attributes": {

        "requiresPeriodicRefresh": "true",

        "isPreHire": {

            "attributes": {

                "negativeCondition": "no",

                "positiveCondition": "yes",

                "firstDate": "now",

                "operator": "lt",

                "secondDate": {

                    "attributes": {

                        "inputFormat": "yyyy-MM-dd",

                        "outputFormat": "ISO8601",

                        "input": {

                            "attributes": {

                                "attributeName": "startDate",

                                "sourceName": "LDAP 2"

                            },

                            "type": "accountAttribute"

                        }

                    },

                    "type": "dateFormat"

                }

            },

            "type": "dateCompare"

        },

        "isTerminated": {

            "type": "firstValid",

            "attributes": {

                "values": [

                    {

                        "type": "dateCompare",

                        "attributes": {

                            "negativeCondition": "no",

                            "positiveCondition": "yes",

                            "firstDate": "now",

                            "operator": "gt",

                            "secondDate": {

                                "attributes": {

                                    "inputFormat": "yyyy-MM-dd",

                                    "outputFormat": "ISO8601",

                                    "input": {

                                        "attributes": {

                                            "attributeName": "exitDate",

                                            "sourceName": "LDAP 2"

                                        },

                                        "type": "accountAttribute"

                                    }

                                },

                                "type": "dateFormat"

                            }

                        }

                    },

                    {

                        "type": "static",

                        "attributes": {

                            "value": "{null}"

                        }

                    }

                ]

            }

        },
 "value": "#if($isPreHire=='yes')preActive#elseif($isTerminated != '{null}' && $isTerminated=='yes')inactive#elseif($isPreHire=='no')active{else}unknown#end"

    },

    "internal": false

```

---

<div class="post-metadata">

**Author:** ![ashutosh08](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ashutosh08/32/11459_2.png) [@ashutosh08](https://developer.sailpoint.com/discuss/u/ashutosh08)\
**Post date:** [May 24, 2024, 12:10pm UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/2 "2024-05-24T12:10:21Z")

</div>

Hi @Polarao

Welcome to SailPoint developer community.

You can add the below snippet in your static transform along with the existing one then adjust your value script.I have assumed that the expiration date source is same only, you may change it according to your need.

Let me know if you further need support.

```auto
{
    "attributes": {
        "firstDate": {
            "attributes": {
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "ISO8601",
                "input": {
                    "attributes": {
                        "attributeName": "expirationDate",
                        "sourceName": "LDAP 2"
                    },
                    "type": "accountAttribute"
                }
            },
            "type": "dateFormat"
        },
        "secondDate": {
            "attributes": {
                "inputFormat": "yyyy-MM-dd",
                "outputFormat": "ISO8601",
                "input": {
                    "attributes": {
                        "attributeName": "exitDate",
                        "sourceName": "LDAP 2"
                    },
                    "type": "accountAttribute"
                }
            },
            "type": "dateFormat"
        },
        "operator": "gt",
        "positiveCondition": "IS_Expired",
        "negativeCondition": "Not Expired"
    },
    "type": "dateCompare",
    "name": "Date Compare Transform"
}

```

---

<div class="post-metadata">

**Author:** ![Polarao](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@Polarao](https://developer.sailpoint.com/discuss/u/Polarao)\
**Post date:** [May 24, 2024, 2:53pm UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/3 "2024-05-24T14:53:46Z")

</div>

Thank you. My requirement is that the end date is valid and greater than the expiry date, then it needs to check again if the expiry date is valid compared to the current date. If it is valid, then it should display “Isexpired”.

---

<div class="post-metadata">

**Author:** ![ashutosh08](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ashutosh08/32/11459_2.png) [@ashutosh08](https://developer.sailpoint.com/discuss/u/ashutosh08)\
**Post date:** [May 24, 2024, 3:35pm UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/4 "2024-05-24T15:35:39Z")

</div>

Hi @Polarao,

Please take a look on the below logic, it utilizes dateCompare and combines your static transform.  
This you can use as one of the inputs in your static transform. You may adjust the values as per need.

```auto
{
    "type": "static",
    "attributes": {
        "requiresPeriodicRefresh": "true",
        "firstValidation": {
            "attributes": {
                "firstDate": {
                    "attributes": {
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601",
                        "input": {
                            "attributes": {
                                "attributeName": "expirationDate",
                                "sourceName": "LDAP 2"
                            },
                            "type": "accountAttribute"
                        }
                    },
                    "type": "dateFormat"
                },
                "secondDate": {
                    "attributes": {
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601",
                        "input": {
                            "attributes": {
                                "attributeName": "exitDate",
                                "sourceName": "LDAP 2"
                            },
                            "type": "accountAttribute"
                        }
                    },
                    "type": "dateFormat"
                },
                "operator": "gt",
                "positiveCondition": "Valid",
                "negativeCondition": "InValid"
            },
            "type": "dateCompare"
        },
        "secondValidation": {
            "type": "dateCompare",
            "attributes": {
                "negativeCondition": "InValid",
                "positiveCondition": "Valid",
                "firstDate": "now",
                "operator": "gt",
                "secondDate": {
                    "attributes": {
                        "inputFormat": "yyyy-MM-dd",
                        "outputFormat": "ISO8601",
                        "input": {
                            "attributes": {
                                "attributeName": "expirationDate",
                                "sourceName": "LDAP 2"
                            },
                            "type": "accountAttribute"
                        }
                    },
                    "type": "dateFormat"
                }
            }
        }
    },
    "value": "#if($firstValidation=='Valid' && secondValidation=='Valid')IsExpired{else}unknown#end"
}

```

---

<div class="post-metadata">

**Author:** ![polaraojalligampala](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@polaraojalligampala](https://developer.sailpoint.com/discuss/u/polaraojalligampala)\
**Post date:** [May 29, 2024, 2:19pm UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/5 "2024-05-29T14:19:49Z")

</div>

Hi Ashutosh,  
Thanks for your support. The earlier transfer you provided is working perfectly as expected.

---

<div class="post-metadata">

**Author:** ![ashutosh08](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ashutosh08/32/11459_2.png) [@ashutosh08](https://developer.sailpoint.com/discuss/u/ashutosh08)\
**Post date:** [May 29, 2024, 2:34pm UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/6 "2024-05-29T14:34:30Z")

</div>

Hi @polaraojalligampala,

Feel free to mark the response as solution if it resolved your query.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 28, 2024, 2:35pm UTC](https://developer.sailpoint.com/discuss/t/transformation-for-setup-lifecycle-state/57909/7 "2024-07-28T14:35:15Z")

</div>

Closed on July 28, 2024, 2:35pm UTC

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