Transform - To check length

We are working on the requirement based on the length of the idenity attribute. If the length of lastname is less than 4, it should return the last name, if its greater than 4 it should return the first 4 character of the lastname, if its null it should return empty string.
Can this be implemented using transform? what can be the operation used for the transform where length of lastname can be checked?

Hi @Dharani_01,

Use below transform, make changes as per your requirement and source details:

{
    "name": "TRN LastName",
    "type": "static",
    "attributes": {
        "lastName": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "lastName",
                            "sourceName": "Your source name"
                        },
                        "type": "accountAttribute"
                    },
                    "null"
                ]
            },
            "type": "firstValid"
        },
        "value": "#if($lastName!='null' && $lastName.length()<4)$lastName#elseif($lastName!='null' && $lastName.length()>4)$lastName.substring(0,3)#{else}#end"
    },
    "internal": false
}

If you are looking for Identity attribute just change the section where we are getting the lastName directly from source attribute. (instead, you can simply use identityAttribute transform)

8 Likes

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