Transform to count input characters

I need to create a transform that count input characters. For example:

An HR code input that comes in the format 006912 would keep the original value. When only 6912 comes, two zeros will be added in front, making it 006912. I haven’t found any transform that counts the number of characters. Can someone help me?

Hello @raibom,

Would the Left Pad | SailPoint Developer Community work for you? If not, I believe you can use $variable.length() in a static transforms value attribute.

3 Likes

As Braden noted, it sounds like the leftPad primitive does what you’re ultimately looking to do here, prepend 0s until the string is the correct length.

If you still need to get the length, you’d use the Static primitive and use Velocity code within the value:

{
    "name": "getLength",
    "type": "static",
    "attributes": {
        "email": {
            "attributes": {
                "name": "email"
            },
            "type": "identityAttribute"
        },
        "value": "$email.length()"
    }
}
2 Likes

hi @raibom ,

I believe you are looking for something which is mentioned in this example.

If your use case matches the same you can use it or else use other transform to find the length and add 0’s

thanks,
Uday

1 Like

Thank you guys, your guidance was very helpful.

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