Odd Error message with Velocity code

I am currently working on being able to dynamically set a Boolean value. I am still really new to Velocity code so I might have made a mistake in my logic.

Use Case

If a user is in a prehire state set value to true else set value to false.
While user is in a prehire state AD should be disabled. Other wise AD should be enabled.

Error message

{2C786DC7-DE28-4B7A-B5AF-A01A11239F4A}

Json

        {
            "name": "IIQDisabled",
            "transform": {
                "attributes": {
                    "currentLCS": {
                        "type": "identityAttribute",
                        "attributes": {
                            "name": "cloudLifecycleState"
                        }
                    },
                    "value": "#if($currentLCS=='prehire')true#{else}false#end"
                },
                "type": "static"
            },
            "attributes": {},
            "isRequired": false,
            "type": "boolean",
            "isMultiValued": false
        },

I was able to get this transform to set a true/false value:

{
    "name": "IIQDisabled",
    "type": "static",
    "attributes": {
        "CurrentLCS": {
            "attributes": {
                "name": "cloudLifecycleState"
            },
            "type": "identityAttribute"
        },
        "value": "#if($CurrentLCS == 'active')false#{else}true#end"
    },
    "internal": false
}

One note, I did switch the order of the if - set the value to false (i.e., enabled) when the LCS is active; otherwise set the value to false. That way only the active LCS will be enabled all other states disabled without having to include every state in the transform.

2 Likes

I was also able to get it working once I fixed the variable in the if statement. Thank you for the response.
Root cause of the error message was the missing $ for the variable.

1 Like

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