Transform logic for account attribute not exists

Hello,
I am using conditional transform to set a value for an identity attribute. I am checking to see if the account exists and if not, set the value to no. This criteria will be using in roles to create new accounts for salesforce new hires.

The identity attribute would be “Salesforce account exists”

{
  "attributes": {
    "expression": "$UserType eq Standard",
    "positiveCondition": "yes",
    "negativeCondition": "no",
    "UserType": {
      "attributes": {
        "sourceName": "Salesforce",
        "attributeName": "UserType"
      },
      "type": "accountAttribute"
    }
  },
  "type": "conditional",
  "name": "Test Salesforce accoutnt exists"
}

I am getting the following error “There was an exception while calculating the value for this attribute. Error rendering template: $UserType eq Standard”

This would be because $Usertype in the account attribute does not exist for some identities since the account was never created.

Can you tell me if there is a way I can achieve this? Thank you.

Try making the UserType be a first valid, so that if account attribute does not exists, it will fall back to a default value.

1 Like

Right now the ‘UserType’ variable is filled with an accountAttribute transform. I would make this a ‘firstvalid’ transform where you first use the accountAttribute transform and then set a static value like “None”. This would look something like so:

{
  "attributes": {
    "expression": "$UserType eq Standard",
    "positiveCondition": "yes",
    "negativeCondition": "no",
    "UserType": {
      "type": "firstValid",
      "attributes": {
        "ignoreErrors": "true",
        "values": [
          {
            "attributes": {
              "sourceName": "Salesforce",
              "attributeName": "UserType"
            },
            "type": "accountAttribute"
          },
          "NONE"
        ]
      }
    }
  },
  "type": "conditional",
  "name": "Test Salesforce accoutnt exists"
}
3 Likes