# Transform - To check length

**URL:** <https://developer.sailpoint.com/discuss/t/transform-to-check-length/84237>\
**Category:** SHF Discussion and Questions\
**Tags:** identityiq, transforms, identity-security-cloud\
**Created:** [October 7, 2024, 12:59pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-check-length/84237 "2024-10-07T12:59:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_01](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@Dharani\_01](https://developer.sailpoint.com/discuss/u/Dharani_01)\
**Post date:** [October 7, 2024, 12:59pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-check-length/84237/1 "2024-10-07T12:59:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![shekhardas1825](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/shekhardas1825/32/20889_2.png) [@shekhardas1825](https://developer.sailpoint.com/discuss/u/shekhardas1825)\
**Post date:** [October 7, 2024, 1:23pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-check-length/84237/2 "2024-10-07T13:23:03Z")

</div>

Hi @Dharani_01,

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

```auto
{
    "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)

---

<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:** [December 6, 2024, 1:23pm UTC](https://developer.sailpoint.com/discuss/t/transform-to-check-length/84237/3 "2024-12-06T13:23:56Z")

</div>

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