# Transform Sample

**URL:** <https://developer.sailpoint.com/discuss/t/transform-sample/7508>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, sailpoint-identity-security\
**Created:** [January 12, 2023, 5:25pm UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508 "2023-01-12T17:25:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashutosh](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@ashutosh](https://developer.sailpoint.com/discuss/u/ashutosh)\
**Post date:** [January 12, 2023, 5:25pm UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508/1 "2023-01-12T17:25:54Z")

</div>

Hi All,

I am trying to calculate lifecycle state using transform but even though transform is created by during user’s lifecycle state calculation it is giving below error.

Any help is much appreciated.

**Transform:**

```auto
{
        "name": "LifeCycle State Transform V1",
        "type": "static",
        "attributes": {
            "assignmentStatus": {
                "attributes": {
                    "sourceName": "CenterPoint Dev1",
                    "attributeName": "ASSIGNMENT_STATUS"
                },
                "type": "accountAttribute"
            },
            "reasonCode": {
                "attributes": {
                    "sourceName": "CenterPoint Dev1",
                    "attributeName": "ReasonCode"
                },
                "type": "accountAttribute"
            },
            "adID": {
                "attributes": {
                    "sourceName": "CenterPoint Dev1",
                    "attributeName": "AD_ID"
                },
                "type": "accountAttribute"
            },
            "value": "#if($assignmentStatus && $assignmentStatus=='ACTIVE' && $adID)active#elseif($assignmentStatus && $assignmentStatus=='ACTIVE' && $reasonCode &&($reasonCode=='INACTIVE_PAYROLL' || $reasonCode=='NO_PAYROLL'))leaveofabsence#elseif($assignmentStatus && $assignmentStatus=='ACTIVE')newhire#elseif($assignmentStatus && $assignmentStatus=='INACTIVE')inactive#{else}unknown#end"
        }
}

```

**Error:**

```auto
com.sailpoint.seaspray.template.TemplateException: Error rendering template: #if($assignmentStatus && $assignmentStatus=='ACTIVE' && $adID)active#elseif($assignmentStatus && $assignmentStatus=='ACTIVE' && $reasonCode &&($reasonCode=='INACTIVE_PAYROLL' || $reasonCode=='NO_PAYROLL'))leaveofabsence#elseif($assignmentStatus && $assignmentStatus=='ACTIVE')newhire#elseif($assignmentStatus && $assignmentStatus=='INACTIVE')inactive#{else}unknown#end

```

Thanks

---

<div class="post-metadata">

**Author:** ![tyler\_mairose](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/tyler_mairose/32/30112_2.png) [@tyler\_mairose](https://developer.sailpoint.com/discuss/u/tyler_mairose)\
**Post date:** [January 12, 2023, 8:28pm UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508/2 "2023-01-12T20:28:04Z")

</div>

Hello @ashutosh,

The transform looks like it should work. In the past some users have had issues with spaces in the value key of the static transform. Can you test out the transform below where I removed the spaces?

```auto
{
        "name": "LifeCycle State Transform V1",
        "type": "static",
        "attributes": {
            "assignmentStatus": {
                "attributes": {
                    "sourceName": "CenterPoint Dev1",
                    "attributeName": "ASSIGNMENT_STATUS"
                },
                "type": "accountAttribute"
            },
            "reasonCode": {
                "attributes": {
                    "sourceName": "CenterPoint Dev1",
                    "attributeName": "ReasonCode"
                },
                "type": "accountAttribute"
            },
            "adID": {
                "attributes": {
                    "sourceName": "CenterPoint Dev1",
                    "attributeName": "AD_ID"
                },
                "type": "accountAttribute"
            },
            "value": "#if($assignmentStatus&&$assignmentStatus=='ACTIVE'&&$adID)active#elseif($assignmentStatus&&$assignmentStatus=='ACTIVE'&&$reasonCode&&($reasonCode=='INACTIVE_PAYROLL'||$reasonCode=='NO_PAYROLL'))leaveofabsence#elseif($assignmentStatus&&$assignmentStatus=='ACTIVE')newhire#elseif($assignmentStatus&&$assignmentStatus=='INACTIVE')inactive#{else}unknown#end"
        }
}

```

---

<div class="post-metadata">

**Author:** ![sharvari](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@sharvari](https://developer.sailpoint.com/discuss/u/sharvari)\
**Post date:** [January 13, 2023, 5:36am UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508/3 "2023-01-13T05:36:36Z")

</div>

You can get this error sometimes if any of those $ variables are null or don’t have values. So before evaluating them in #if it’s always better to check that those values are non null explicitly.

You may try it like this:

```auto
"assignmentStatus" : {
    "attributes": {
        "values": [
            {
                "attributes": {
                    "attributeName": "ASSIGNMENT_STATUS",
                    "sourceName": "CenterPoint Dev1"
                },
                "type": "accountAttribute"
            },
            {
                "attributes": {
                    "value": "NONE"
                },
                "type": "static"
            }
        ]
    },
    "type": "firstValid"
}

"value": "#if($assignmentStatus != 'NONE' && $assignmentStatus == 'ACTIVE')
 

```

---

<div class="post-metadata">

**Author:** ![ashutosh](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@ashutosh](https://developer.sailpoint.com/discuss/u/ashutosh)\
**Post date:** [January 13, 2023, 9:24am UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508/4 "2023-01-13T09:24:08Z")

</div>

Thanks for your input .I was able to resolve it.

---

<div class="post-metadata">

**Author:** ![ashutosh](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@ashutosh](https://developer.sailpoint.com/discuss/u/ashutosh)\
**Post date:** [January 13, 2023, 9:24am UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508/5 "2023-01-13T09:24:55Z")

</div>

Thanks for the input. The issue was with null values which I was able to resolve using firstValid.

---

<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 19, 2023, 2:24pm UTC](https://developer.sailpoint.com/discuss/t/transform-sample/7508/6 "2023-07-19T14:24:05Z")

</div>

Closed on July 19, 2023, 2:24pm UTC


