Create profile display name getting space

I have below mapped displayName in create profile and there are few employee type don’t have $ccad. when there no $ccad I am getting space at the end of display name.

Any idea how to remove that space when there is no $ccad.

<AttributeRequest name="displayName" op="Add" value="SPTest, SkeTestd "/>
{
            "name": "displayName",
            "transform": {
                "type": "rule",
                "attributes": {
                    "name": "Create Unique LDAP Attribute"
                }
            },
            "attributes": {
                "template": "$(lastname), $(firstname)$(uniqueCounter) $(ccad)"
            },
            "isRequired": false,
            "type": "string",
            "isMultiValued": false
        }

HI @gayare,

You can add Trim operation in transform to remove any extra spaces.

Thanks.

You can use Replace or ReplaceAll transform and replace space with empty string “”.
Here is the reference if you are using Replace.Replace | SailPoint Developer Community

As you are using a Generator in create profile, I don’t think you will be able to wrap it with any transform. Only thing I can think of is to have another Identity attribute (say named ccad1) and apply a transform to it which will have " valueOf_ccad" when ccad has a value, and an empty string when ccad is empty. Then use the ccad1 attribute in the template for Generator rule