Calculating the email id using transform based on the company name

Hi Team,
Currently, we use a Cloud Rule to generate the email ID in Active Directory (AD) when a user is created. The rule calculates the email ID based on the company name and sets the workEmail attribute using the firstValid transform, retrieving the email ID from AD or, if unavailable, from the UKG source, then assigning it to the authoritative source identity profile.

Requirement:

We need to standardize the email ID format for all company types when a user is created. Instead of modifying the script, we prefer to update the transform used to calculate the workEmail attribute.

Issue:

The transform logic was updated, but it is not returning any values Below is the transform logic that needs correction.
{
“name”: "Transform “,
“type”: “static”,
“attributes”: {
“hasmail”: {
“type”: “firstValid”,
“values”: [
{
“type”: “accountAttribute”,
“attributes”: {
“sourceName”: Active Directory”,
“attributeName”: “mail”
}
},
{
“type”: “accountAttribute”,
“attributes”: {
“sourceName”: “xxxxxxx”,
“attributeName”: “Email Address”
}
}
]
},
“replace”: {
“type”: “replace”,
“attributes”: {
“regex”: “xxxxxxxx.com”,
“replacement”: “xxxxxx.com
}
}
},
“internal”: false
}

Hi @sgonuguntla

Escaping Regex Special Characters:

  • Crucial: In regular expressions, a dot . is a special character that matches any single character. If you want to match a literal dot, you must escape it with a backslash \. So, xxxxxxxx.com should become xxxxxxxx\\.com.
 "regex": "xxxxxxxx\\.com",
    "replacement": "xxxxxx.com"

Thanks. tried adding \ before dot but it is also not working

Hi @sgonuguntla - I think there may be a number of errors in your transform.

  1. static transforms need a value attribute
  2. replace transforms need an input attribute or it’s expecting it to be passed via the UI config

I recommend breaking your transform down into smaller chunks and then building it up. ie start with the firstValid and build from there. Or if you want to check your replace, start there with static input value.

Static transforms and lookup transforms might help

Apols, I see that you have started with a working firstValid (although your AD source name appears to be missing a quote). Add the firstValid as the input attribute of the replace transform. Not sure you actually need the static transform as a wrapper.