Transform error

Hello,
I wrote this transform:

{
    "name": "Transform - Username choice",
    "type": "static",
    "attributes": {
        "ignoreErrors": "true",
        "USER_NAME": {
            "attributes": {
                "sourceName": "HR Oracle HCM Cloud (Source)",
                "attributeName": "USER_NAME"
            },
            "type": "accountAttribute"
        },
        "PERSON_NUMBER": {
            "attributes": {
                "sourceName": "HR Oracle HCM Cloud (Source)",
                "attributeName": "PERSON_NUMBER"
            },
            "type": "accountAttribute"
        },
        "sAMAccountName": {
            "attributes": {
                "sourceName": "AD Tier 2 (Source)",
                "attributeName": "sAMAccountName"
            },
            "type": "accountAttribute"
        },
        "value": "#if(!$USER_NAME) #if(!$sAMAccountName) $PERSON_NUMBER #else $sAMAccountName #end #else $USER_NAME #end"
    }
}

But it gives me this error:

There was an exception while calculating the value for this attribute. Error during transformation for attribute: uid (Transform ID: Transform - Username choice) Cause: Error rendering template: #if(!$USER_NAME) $PERSON_NUMBER #else $USER_NAME #end

The problem is in the management of null values I think, because when the USER_NAME attribute is null I get this error. Do you know to manage empty attributes? Thanks in advance

Hi @l_pulignano

Based on your information , error is occurred to due improper null check .
We need to user First Valid Transform to encounter Null Checks .

This is a reference example which is also alternative of what you are trying to acheive:

{
  "attributes": {
    "values": [
      {
        "attributes": {
          "sourceName": "Active Directory",
          "attributeName": "sAMAccountName"
        },
        "type": "accountAttribute"
      },
      {
        "attributes": {
          "sourceName": "Okta",
          "attributeName": "login"
        },
        "type": "accountAttribute"
      },
      {
        "attributes": {
          "sourceName": "HR Source",
          "attributeName": "employeeID"
        },
        "type": "accountAttribute"
      }
    ]
  },
  "type": "firstValid",
  "name": "Test First Valid Transform"
}

Please refer the below for more understanding: First Valid | SailPoint Developer Community

Hope this helps !
Thanks :slight_smile:

1 Like

Yes, as Sidharth mentioned,

You can use first valid Transform to fulfil your requirement.

For future use cases, where you need to use Static Transform, remember that, every attribute you define inside Static transform should have a value, if not it will throw an exception. So, you should use first valid type Transform for every attribute you declare inside Static Transform.

{
    "type": "static",
    "attributes": {
        "variable1": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "",
                            "attributeName": ""
                        }
                    },
                    "none"
                ]
            }
        },
        "variable2": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "",
                            "attributeName": ""
                        }
                    },
                    "none"
                ],
                "ignoreErrors": false
            }
        
        },
        "value": "#if($variable1 != 'none')do something#end"
    }
}
1 Like

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