# DateCompare Transform error

**URL:** <https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, sailpoint-identity-security\
**Created:** [April 2, 2024, 4:21am UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670 "2024-04-02T04:21:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhayes9090](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@jhayes9090](https://developer.sailpoint.com/discuss/u/jhayes9090)\
**Post date:** [April 2, 2024, 4:21am UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/1 "2024-04-02T04:21:40Z")

</div>

Im receiving the below error in IDN for my lcs attribute. I cant seem to figure out why the error is generating. Im attempting to add 30days to the term date and compare to the system date and return true or false

There was an exception while calculating the value for this attribute. Error rendering template: #if($lsState == ‘inactive’ && $30DayPastEndDateCheck == ‘true’) terminated #elseif($lsState == ‘rehire’) prehire #else $lsState #end

Close

```auto
{
    "name": "LCS Status",
    "type": "static",
    "attributes": {
        "lsState": {
            "type": "accountAttribute",
            "attributes": {
                "sourceName": "Workday (R1)",
                "attributeName": "LifecycleStatus__c"
            }
        },
        "30DayPastEndDateCheck": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateMath",
                    "attributes": {
                        "expression": "+30d",
                        "input": {
                            "type": "dateFormat",
                            "attributes": {
                                "input": {
                                    "type": "accountAttribute",
                                    "attributes": {
                                        "sourceName": "Workday",
                                        "attributeName": "LAST_DAY_OF_WORK"
                                    }
                                },
                                "inputFormat": "MM/dd/yyyy",
                                "outputFormat": "ISO8601"
                            }
                        }
                    }
                },
                "secondDate": {
                    "type": "dateMath",
                    "attributes": {
                        "expression": "now",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        },
        "value": "#if($lsState == 'inactive' && $30DayPastEndDateCheck == 'true') terminated #elseif($lsState == 'rehire') prehire #else $lsState #end"
    }
}

```

---

<div class="post-metadata">

**Author:** ![schattopadhy](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/schattopadhy/32/8854_2.png) [@schattopadhy](https://developer.sailpoint.com/discuss/u/schattopadhy)\
**Post date:** [April 2, 2024, 5:57am UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/2 "2024-04-02T05:57:52Z")

</div>

@jhayes9090 try to check if these two values are coming up or not looks the the value lsState and date one is not able to generate,try testing them individually if you get any value and see

---

<div class="post-metadata">

**Author:** ![jesvin90](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jesvin90/32/5301_2.png) [@jesvin90](https://developer.sailpoint.com/discuss/u/jesvin90)\
**Post date:** [April 2, 2024, 7:36am UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/4 "2024-04-02T07:36:35Z")

</div>

Hi @jhayes9090,

Can you try this in the velocity template and see if it works:

`"value": "#if($lsState == 'inactive' && $30DayPastEndDateCheck == 'true')terminated#elseif($lsState == 'rehire')prehire#{else}$lsState#end"`

If not, I would try using the below values in the velocity template to see if it shows the expected values :

> “value”:$lsState
> 
> “value”:$30DayPastEndDateCheck

---

<div class="post-metadata">

**Author:** ![schattopadhy](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/schattopadhy/32/8854_2.png) [@schattopadhy](https://developer.sailpoint.com/discuss/u/schattopadhy)\
**Post date:** [April 2, 2024, 12:04pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/6 "2024-04-02T12:04:16Z")

</div>

@jhayes9090 please try this code and let us know update it as per your requirement

```auto
        "id": "103870c8-a87f-4c1e-9965-00ca5c580660",
        "name": "LCS Status",
        "type": "static",
        "attributes": {
            "lsState": {
                "attributes": {
                    "values": [
                        {
                            "attributes": {
                            "value": "inactive"
                        },
                        "type": "static"
                        },
                        ""
                    ]
                },
                "type": "firstValid"
            },
            "value": "#if($lsState=='inactive' && $checkdate == 'true')terminated#elseif($lsState == 'rehire')prehire#{else}$checkdate#{end}",
            "checkdate": {
               "attributes": {
                    "secondDate": {
                        "attributes": {
                            "expression": "now",
                            "roundUp": false
                        },
                        "type": "dateMath"
                    },
                    "negativeCondition": {
                        "attributes": {
                            "value": "true"
                        },
                        "type": "static"
                    },
                    "operator": "gte",
                    "positiveCondition": {
                        "attributes": {
                            "value": "false"
                        },
                        "type": "static"
                    },
                    "firstDate": {
                        "type": "dateMath",
                    "attributes": {
                        "expression": "now+30d",
                        "input": {
                            "type": "dateFormat",
                            "attributes": {
                                "input": {
                                    "type": "accountAttribute",
                                    "attributes": {
                                        "sourceName": "Hr Non Emp Hari",
                                        "attributeName": "endDate"
                                    }
                                },
                                "inputFormat": "MM/dd/yyyy",
                                "outputFormat": "ISO8601"
                            }
                        }
                    }
                    }
                },
                "type": "dateCompare"
            }
        },
        "internal": false
    }
type or paste code here

```

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 2, 2024, 1:42pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/7 "2024-04-02T13:42:58Z")

</div>

try this…

```auto
{
    "name": "LCS Status",
    "type": "static",
    "attributes": {
        "value": "#if($lsState == 'inactive' && $30DayPastEndDateCheck == 'true') terminated #elseif($lsState == 'rehire') prehire #else $lsState #end",
        "lsState": {
            "type": "accountAttribute",
            "attributes": {
                "sourceName": "Workday (R1)",
                "attributeName": "LifecycleStatus__c"
            }
        },
        "30DayPastEndDateCheck": {
            "type": "dateCompare",
            "attributes": {
                "firstDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input": {
                            "type": "firstValid",
                            "attributes": {
                                "values": [
                                    {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "sourceName": "Workday",
                                            "attributeName": "LAST_DAY_OF_WORK"
                                        }
                                    },
                                    "12/31/2124"
                                ]
                            }
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    }
                },
                "secondDate": {
                    "type": "dateFormat",
                    "attributes": {
                        "input":{
                            "type": "dateMath",
                            "attributes": {
                                "expression": "now-30d/d",
                                "roundUp": false
                            }
                        },
                        "inputFormat": "yyyy-MM-dd'T'HH:mm",
                        "outputFormat": "ISO8601"
                    }
                },
                "operator": "lte",
                "positiveCondition": "true",
                "negativeCondition": "false"
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Jhayes90](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@Jhayes90](https://developer.sailpoint.com/discuss/u/Jhayes90)\
**Post date:** [April 2, 2024, 2:21pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/8 "2024-04-02T14:21:53Z")

</div>

Hi Nithesh,

I tried your block and I still receive same error. I did a test and set value to both lsState and 30DayPastEndDateCheck. I receive the value for lsState but 30DayPastEndDateCheck prints out “$30DayPastEndDateCheck”. So it doesnt render the logic it encapsulates

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 2, 2024, 2:33pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/9 "2024-04-02T14:33:58Z")

</div>

Apparently using a number in the beginning of a variable does not work with Velocity templates. Change `30DayPastEndDateCheck` to `Check30DayPastEndDate`

---

<div class="post-metadata">

**Author:** ![Jhayes90](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@Jhayes90](https://developer.sailpoint.com/discuss/u/Jhayes90)\
**Post date:** [April 2, 2024, 2:51pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/10 "2024-04-02T14:51:31Z")

</div>

Thanks! It works now

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [April 2, 2024, 3:09pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/11 "2024-04-02T15:09:00Z")

</div>

Good to know… Just a note to add here. In your original transform you had used `dateMath` directly for `firstDate` and `secondDate`. But these 2 fields need inputs in ISO8601 format and `dateMath` does not have output in this format.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/3/3730c65aa3daf9d4f52ab68f78688ca91ddec311.png)  
Hence, you need to wrap `dateMath` with a `dateFormat` tranform before using it in `dateCompare`

---

<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:** [June 1, 2024, 3:09pm UTC](https://developer.sailpoint.com/discuss/t/datecompare-transform-error/38670/12 "2024-06-01T15:09:28Z")

</div>

Closed on June 1, 2024, 3:09pm UTC

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