Error in a transform: "There was an exception while calculating the value for this attribute."

Hello,
I have an error on a transform. I tried to wrote it in two different ways

As a concat transform

{
    "id": "29f31d53-1c4e-4933-86d9-f84b479eff22",
    "name": "Transform - Calculate AD Tier2 UPN",
    "type": "concat",
    "attributes": {
        "values": [
            {
                "type": "static",
                "attributes": {
                    "value": "$identity.getStringAttribute('firstname')"
                }
            },
            ".",
            {
                "type": "static",
                "attributes": {
                    "value": "$identity.getStringAttribute('lastname')"
                }
            },
            "@",
            {
                "attributes": {
                    "personType": {
                        "type": "static",
                        "attributes": {
                            "value": "$identity.getStringAttribute('personType')"
                        }
                    },
                    "value": "#if($personType=='Regular') #set($domainPrefix = '') #else #set($domainPrefix = 'external.') #end $domainPrefix"
                },
                "type": "static"
            },
            {
                "attributes": {
                    "legalEmployerAlias": {
                        "type": "static",
                        "attributes": {
                            "value": "$identity.getStringAttribute('legalEmployerAlias')"
                        }
                    },
                    "value": "#if($legalEmployerAlias=='CAAB') #set($domain = 'ca-autobank') #else #set($domain = 'drivalia') #end $domain"
                },
                "type": "static"
            },
            ".com"
        ]
    },
    "internal": false
}

and as a static one

{
    "name": "Static Transform - Calculate AD Tier2 UPN",
    "type": "static",
    "attributes": {
        "firstName": {
            "attributes": {
                "value": "$identity.getStringAttribute('firstname')"
            },
            "type": "static"
        },
        "lastname": {
            "attributes": {
                "value": "$identity.getStringAttribute('lastname')"
            },
            "type": "static"
        },
        "personType": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "identityAttribute",
                        "attributes": {
                            "attributeName": "personType"
                        }
                    },
                    "-"
                ]}},
        "legalEmployerAlias": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "identityAttribute",
                        "attributes": {
                            "attributeName": "legalEmployerAlias"
                        }
                    },
                    "-"
                ]}},
 
 
            "value": "#if($personType=='Regular') #set($domainPrefix = '') #else #set($domainPrefix = 'external.') #end #if($legalEmployerAlias=='CAAB') #set($domain = 'ca-autobank') #else #set($domain = 'drivalia') #end $firstName.$lastname@$domainPrefixdomain.com"
        },
        "internal": false
    }

The error I get is the following:

There was an exception while calculating the value for this attribute. Error during transformation for attribute: adUpn (Transform ID: Static Transform - Calculate AD Tier2 UPN) Cause: Error rendering template: #if($personType=='Regular') #set($domainPrefix = '') #else #set($domainPrefix = 'external.') #end #if($legalEmployerAlias=='CAAB') #set($domain = 'ca-autobank') #else #set($domain = 'drivalia') #end $firstName.$lastname@$domainPrefixdomain.com

Can you help me? Thanks in advance

Hi Luana,

Is this for a create policy for AD, or for your identity profile? Based on your input above, it looks like it is for an identity profile.

If for your identity profile, instead of going to the identity to get the firstname, lastname, etc., go to your HR data using the accountAttribute transform instead.

Thanks,
Margo

1 Like

Hi @l_pulignano can you try with the below code.

{
    "name": "Static Transform - Calculate AD Tier2 UPN",
    "type": "static",
    "attributes": {
        "firstName": {
         "attributes": {
        "sourceName": "HR Source",
        "attributeName": "firstname"
      },
      "type": "accountAttribute"
        },
        "lastname": {
            "attributes": {
        "sourceName": "HR Source",
        "attributeName": "lastname"
      },
      "type": "accountAttribute"
        },
        "personType": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "identityAttribute",
                        "attributes": {
                            "attributeName": "personType"
                        }
                    },
                    "-"
                ]}},
        "legalEmployerAlias": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "identityAttribute",
                        "attributes": {
                            "attributeName": "legalEmployerAlias"
                        }
                    },
                    "-"
                ]}},
 
 
            "value": "#if($personType==\"Regular\")#set($domainPrefix = '') #else #set($domainPrefix = \"external.\") #end #if($legalEmployerAlias==\"CAAB\") #set($domain = \"ca-autobank\") #else #set($domain = \"drivalia\") #end $firstName.$lastname@$domainPrefixdomain.com"
        },
        "internal": false
    }

Change the HR source to yours.

  1. You don’t need to use VLT script to get Identity attributes, instead use Account Attribute transforms
  2. Whenever you are using some variables inside static transform, if you are referencing that variable in value property using VLT then you should always go with first valid transform for the variable, if there is no value for the user then return some static value, for example

If no value returned for variable then it will throw an error

{
    "type": "static",
    "attributes": {
        "variable1": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "HR",
                            "attributeName": "country"
                        }
                    },
                    "none"
                ]
            }
        
        },
        "value": "#if($variable1 == 'Germany') DE #elseif($variable1 == 'Canada') CA #{else} IN #end"
    }
} 
{    
    "name": "Transform - Calculate AD Tier2 UPN",
    "type": "static",
    "attributes": {
        "firstName": {
            "type": "identityAttribute",
            "attributes": {
                "name": "firstname"
            }
        },
        "lastname": {
            "type": "identityAttribute",
            "attributes": {
                "name": "lastname"
            }
        },
        "subDomain": {
            "type": "static",
            "attributes": {
                "personType": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "type": "identityAttribute",
                                "attributes": {
                                    "attributeName": "personType"
                                }
                            },
                            "NONE"
                        ]
                    }
                },
                "value": "#if($personType != 'Regular')external.#end"
            }
        },
        "mainDomain": {
            "type": "static",
            "attributes": {
                "legalEmployerAlias": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "type": "identityAttribute",
                                "attributes": {
                                    "attributeName": "legalEmployerAlias"
                                }
                            },
                            "NONE"
                        ]
                    }
                },
                "value": "#if($legalEmployerAlias == 'CAAB')ca-autobank#{else}drivalia#end"
            }
        },
        "dotCom": {
            "type": "static",
            "attributes": {
                "value": ".com"
            }
        },
        "value": "$firstName$lastname@$subDomain$mainDomain$dotCom "
    },
    "internal": false
}