How to check account attributes that are null or empty strings using transforms in identity profiles

I want to check account attributes from an authoritative source, for example, the last name attribute. If the attribute is null or an empty string, I want to replace it with first character from firstName attribute.

This is my Transform Code :

{

  "name": "Generate Work Email",

"type": "static",

"attributes": {

"value": {

"type": "lower",

"attributes": {

"input": {

"type": "firstValid",

"attributes": {

"values": [

{

"type": "accountAttribute",

"attributes": {

"sourceName": "HR Employee",

"attributeName": "e-mail"

}

},

{

"type": "concat",

"attributes": {

"values": [

{

"type": "substring",

"attributes": {

"begin": 0,

"end": 1,

"input": {

"type": "identityAttribute",

"attributes": {

"name": "lastname"

}

}

}

},

{

"type": "identityAttribute",

"attributes": {

"name": "firstname"

}

},

{

"type": "static",

"attributes": {

"value": "."

}

},

{

"type": "identityAttribute",

"attributes": {

"name": "lastname"

}

},

{

"type": "static",

"attributes": {

"value": "@domainCompany"

}

}

]

}

},

{

"type": "concat",

"attributes": {

"values": [

{

"type": "substring",

"attributes": {

"begin": 0,

"end": 1,

"input": {

"type": "identityAttribute",

"attributes": {

"name": "firstname"

}

}

}

},

{

"type": "static",

"attributes": {

"value": "."

}

},

{

"type": "identityAttribute",

"attributes": {

"name": "firstname"

}

},

{

"type": "static",

"attributes": {

"value": "@domainCompany"

}

}

]

}

}

]

}

}

}

}

}

}


Hi @rsobar

Example Transform

{
  "type": "firstValid",
  "name": "Last Name with Fallback Transform",
  "attributes": {
    "values": [
      {
        "type": "accountAttribute",
        "attributes": {
          "sourceName": "HR Source",
          "attributeName": "lastName"
        }
      },
      {
        "type": "substring",
        "attributes": {
          "input": {
            "type": "accountAttribute",
            "attributes": {
              "sourceName": "HR Source",
              "attributeName": "firstName"
            }
          },
          "begin": 0,
          "end": 1
        }
      }
    ],
    "ignoreErrors": "true"
  }
}

Thank you
Sid

Hi @sidharth_tarlapally ,
From the example of the transform code you shared, how can I fill in the identity attribute e-mail with the account attribute firstName.lastname@domainCompany, but if the account attribute last name is null or an empty string, the account attribute lastname is taken from the first character of firstName, and the final result will be: Rizal.r@domainCompany

By using a firstValid transform to check the authoritative source ‘lastName'attribute first and, if it is null or an empty/blank string, automatically fall back to the first character of the ‘firstName' attribute. The trim transform ensures that whitespace-only values are treated as empty, while the substring transform extracts the first letter from ‘firstName'. Below is the complete transform configuration that fulfills this requirement:

{
  "type": "firstValid",
  "attributes": {
    "values": [
      {
        "type": "trim",
        "attributes": {
          "input": {
            "type": "accountAttribute",
            "attributes": {
              "sourceName": "HR Source",
              "attributeName": "lastName"
            }
          }
        }
      },
      {
        "type": "substring",
        "attributes": {
          "input": {
            "type": "accountAttribute",
            "attributes": {
              "sourceName": "HR Source",
              "attributeName": "firstName"
            }
          },
          "begin": 0,
          "end": 1
        }
      }
    ]
  }
}

Hi @sidharth_tarlapally @rohitmisal45 ,

Thank you, your solution is very helpful. I’d like to ask: what if I want to add a unique number after the firstName?

@rsobar

for that you’ll have to implement a Cloud Rule :

Thank you