Replace All - Null error

Hello all,

I’ve been working on a transform to determine the length of an identity attribute, which will help in making certain decisions. Below is the transform I used:
I applied the replaceAll transform to remove any null spaces and then nested it with a static transform to calculate the number of characters without spaces

however it is giving null error as :
There was an exception while calculating the value for this attribute. Error during transformation for attribute: adseed (Transform ID: ADseedsrinidhi) Cause: Error running identity attribute transform:java.lang.IllegalArgumentException: Value of ‘name’ cannot be null.

Can someone help on this?

{

"id": "XXXXX",

“name”: “XXXX”,

“type”: “replaceAll”,
“attributes”: {
“table”: {
“\s+”: “”
},
“input”: {
“type”: “static”,
“firstname”: {
“input”: {
“attributes”: {
“type”: “identityAttribute”,
“attributes”: {
“name”: “firstname”
}
},
“lastname”: {
“input”: {
“type”: “identityAttribute”,
“attributes”: {
“name”: “lastname”
}
},
“value”: “$firstname”
}
}
}
}
},

From what I see, this will return a string, not the length.
You must invert the structure. The static transform should be the outermost part of the transform. The static transform is used to execute a Velocity script

Here is an example of what may work, if I’m understanding your use case.

I’m curious as to your use case for needing the length. I have not tested this for you, it may need some additional refinement. My focus was on the order of the transform.

I’m curious as to the use case for needing the length. Are you looking at using it for a sAMAccountName, etc?

{
    "id": "Calculate-Length-Transform",
    "name": "Calculate Length Without Spaces",
    "type": "static",
    "attributes": {
        "inputName": {
            "type": "replaceAll",
            "attributes": {
                "table": {
                    "\\s+": ""
                },
                "input": {
                    "type": "static",
                    "attributes": {
                        "firstname": {
                            "type": "identityAttribute",
                            "attributes": {
                                "name": "firstname"
                            }
                        },
                        "lastname": {
                            "type": "identityAttribute",
                            "attributes": {
                                "name": "lastname"
                            }
                        },
                        "value": "$firstname$lastname"
                    }
                }
            }
        },
        "value": "$inputName.length()"
    }
}

@ts_fpatterson - Thanks for swift reply, but unfortunately this is not working giving same error There was an exception while calculating the value for this attribute. Error during transformation for attribute: adseed (Transform ID: ADseedsrinidhi) Cause: Error rendering template: $inputName.length()

scenario that i want to achieve is, if lastname character is less than 3 , i need to append lastname+firstname for samaccountname

check to see if you are dealing with a null value

#if($inputName)$inputName.length()#else0#end

You may want to do the same for $firstname and $lastname

Hi @nidhipriya,

Can you try below transform once, it works fine for me.

{
"id": "Calculate-Length-Transform",

"name": "Calculate Length Without Spaces",

"type": "static",

"attributes": {

    "lastName": {

        "type": "replaceAll",

        "attributes": {

            "table": {

                "\\s+": ""

            },

            "input": {

                "type": "identityAttribute",

                "attributes": {

                    "name": "lastname"

                }

            }

        }

    },

    "firstName": {

        "type": "identityAttribute",

        "attributes": {

            "name": "firstname"

        }

    },

    "value": "#if($lastName.length() < 3)$lastName$firstName#{else}$lastName#end"

}
2 Likes

@UjjwalJain - Thankyou!!
I am able to correct the transform , its working according to my requirement.

Great to hear the transform works for you!
When you have a moment, please mark this post as solved.

I mean, I was able to build the transform to meet my specific requirements.