Transform Sample

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:

{
        "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:

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

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?

{
        "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"
        }
}

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:

"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')
 

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

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

1 Like