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

**URL:** <https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903>\
**Category:** SHF Discussion and Questions\
**Tags:** identity-security-cloud, transforms\
**Created:** [March 12, 2025, 3:13pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903 "2025-03-12T15:13:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![l\_pulignano](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@l\_pulignano](https://developer.sailpoint.com/discuss/u/l_pulignano)\
**Post date:** [March 12, 2025, 3:13pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903/1 "2025-03-12T15:13:43Z")

</div>

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

As a concat transform

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

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

```auto
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

---

<div class="post-metadata">

**Author:** ![margocbain](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/margocbain/32/17314_2.png) [@margocbain](https://developer.sailpoint.com/discuss/u/margocbain)\
**Post date:** [March 12, 2025, 4:03pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903/2 "2025-03-12T16:03:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [March 12, 2025, 4:07pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903/3 "2025-03-12T16:07:19Z")

</div>

Hi @l_pulignano can you try with the below code.

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

---

<div class="post-metadata">

**Author:** ![KRM7](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/krm7/32/2685_2.png) [@KRM7](https://developer.sailpoint.com/discuss/u/KRM7)\
**Post date:** [March 12, 2025, 6:36pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903/4 "2025-03-12T18:36:06Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [March 12, 2025, 9:06pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903/5 "2025-03-12T21:06:15Z")

</div>

> [@l\_pulignano](#):
>
> and as a static one

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

```

---

<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:** [May 11, 2025, 9:06pm UTC](https://developer.sailpoint.com/discuss/t/error-in-a-transform-there-was-an-exception-while-calculating-the-value-for-this-attribute/103903/6 "2025-05-11T21:06:59Z")

</div>

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