FirstValid Transform not Working ( Provisioning)

Hi Everyone,

Firstvalid transform is not working on provisioning policy, I tried to create email based on two combination like business [email protected] if business names are not available then we have to use regular firstname and lastname from identity profile but it seems to be non working, has anybody face similar challenge??

{
    "type": "lower",
    "attributes": {
        "input": {
            "type": "replaceAll",
            "attributes": {
                "table": {
                    "ä": "ae",
                    "ö": "oe",
                    "ĂĽ": "ue",
                    "Ăź": "ss"
                },
                "input": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "type": "concat",
                                "attributes": {
                                    "values": [
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "bfirstname"
                                            }
                                        },
                                        ".",
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "blastname"
                                            }
                                        },
                                        "@demotest.com"
                                    ]
                                }
                            },
                            {
                                "type": "concat",
                                "attributes": {
                                    "values": [
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "firstname"
                                            }
                                        },
                                        ".",
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "lastname"
                                            }
                                        },
                                        "@demotest.com"
                                    ]
                                }
                            }
                        ]
                    }
                }
            }
        }
    }
}

The transform logic seems fine . But while referring to identity attribute

{
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "FirstName"
                                            }
                                        }

The attributes-name should be technical name case , such as firstname , lastname:

Change the attribute name and try

Thanks

If you need help finding the technical name of the attributes you can see this on the identity profile under mappings.

{D55C8065-63F2-4B76-A1E8-E2377F73CBD7}
The technical name is inside the (). Case is importin when writing transforms or rules.

Hey, I understand that we need to use technical names in transform, that was some typing mistake while indenting, but it’s not working on using technical names even. I corrected now, it seems first valid is not working on provisioning.

Hi @LearningStar ,

In your case, the FirstValid transform will not work because it checks for null values, meaning it will retrieve a value from the Concat transform each time. Instead, I recommend trying the following transform, as I hope it will work for you.

    "name": "EmailFormatTransform",
    "type": "lower",
    "attributes": {
        "input": {
            "type": "static",
            "attributes": {
                "workerType": {
                    "type": "concat",
                    "attributes": {
                        "values": [
                            {
                                "type": "identityAttribute",
                                "attributes": {
                                    "name": "bfirstname"
                                }
                            },
                            ".",
                            {
                                "type": "identityAttribute",
                                "attributes": {
                                    "name": "blastname"
                                }
                            },
                            "@demotest.com"
                        ]
                    }
                },
                "workerType01": {
                    "type": "concat",
                    "attributes": {
                        "values": [
                            {
                                "type": "identityAttribute",
                                "attributes": {
                                    "name": "firstname"
                                }
                            },
                            ".",
                            {
                                "type": "identityAttribute",
                                "attributes": {
                                    "name": "lastname"
                                }
                            },
                            "@demotest.com"
                        ]
                    }
                },
                "value": "#if($workerType=='[email protected]')$workerType01#{else}$workerType#end"
            }
        }
    },
    "internal": false
}

Thank You.

1 Like

Your first value will always return something, so it will never fall back to your second value. If you want to check for individual null attributes, then wrap each attribute in a “firstValid”. Also, it’s generally best to include the “ignoreErrors”: true argument to your firstValid transforms:

{
    "type": "lower",
    "attributes": {
        "input": {
            "type": "replaceAll",
            "attributes": {
                "table": {
                    "ä": "ae",
                    "ö": "oe",
                    "ĂĽ": "ue",
                    "Ăź": "ss"
                },
                "input": {
                    "type": "concat",
                    "attributes": {
                        "values": [
                            {
                                "type": "firstValid",
                                "attributes": {
									"ignoreErrors":true,
                                    "values": [
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "bfirstname"
                                            }
                                        },
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "firstname"
                                            }
                                        }
                                    ]
                                }
                            },
							".",
                            {
                                "type": "firstValid",
                                "attributes": {
									"ignoreErrors":true,
                                    "values": [
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "blastname"
                                            }
                                        },
                                        {
                                            "type": "identityAttribute",
                                            "attributes": {
                                                "name": "lastname"
                                            }
                                        }
                                    ]
                                }
                            },
							"@demotest.com"
                        ]
                    }
                }
            }
        }
    }
}

Hi @LearningStar try the below transform.

{
“name”: “TRN Generate mail”,
“type”: “static”,
“attributes”: {
“BusinessFN”: {
“attributes”: {
“input”: {
“attributes”: {
“values”: [
{
“attributes”: {
“sourceName”: “HR Success Factors”,
“attributeName”: “BusinessFirstname”
},
“type”: “accountAttribute”
},
“null”,
]
},
“type”: “firstValid”
}
},
“type”: “lower”
},
“BusinessLN”: {
“attributes”: {
“input”: {
“attributes”: {
“values”: [
{
“attributes”: {
“sourceName”: “HR Success Factors”,
“attributeName”: “FuturePreferredLastName”
},
“type”: “accountAttribute”
},
“null”,
]
},
“type”: “firstValid”
}
},
“type”: “lower”
},
“FN”: {
“attributes”: {
“input”: {
“attributes”: {
“values”: [

                                    {
                                        "attributes": {
                                            "sourceName": "HR Success Factors",
                                            "attributeName": "FirstName"
                                        },
                                        "type": "accountAttribute"
                                    },
									"null",
                                ]
                            },
                            "type": "firstValid"
							 }
            },
            "type": "lower"
        },
		 "LN": {
			 "attributes": {
                "input": {
			 "attributes": {
                                "values": [
                                  
                                    {
                                        "attributes": {
                                            "sourceName": "HR Success Factors",
                                            "attributeName": "LastName"
                                        },
                                        "type": "accountAttribute"
                                    },
									"null",
                                ]
                            },
                            "type": "firstValid"
							 }
            },
            "type": "lower"
        },
        "value": "#if($BusinessFN!= 'null' && $BusinessLN!= 'null')[email protected]#elseif($FN!= 'null' && $LN!= 'null')[email protected]#{else}#end"
    }
}
3 Likes

Let me know if it works.

3 Likes

Hi Gagan,

I believe this transform will give the output you are expecting. Please try it out, and let me know if you face any issue.

  "name": "EmailFormatTransform",
  "type": "replaceAll",
  "attributes": {
    "table": {
      "ä": "ae",
      "ö": "oe",
      "ĂĽ": "ue",
      "Ăź": "ss"
    },
    "input": {
      "type": "lower",
      "attributes": {
        "input": {
          "type": "static",
          "attributes": {
            "workerType": {
              "type": "concat",
              "attributes": {
                "values": [
                  {
                    "type": "identityAttribute",
                    "attributes": {
                      "name": "bfirstname"
                    }
                  },
                  ".",
                  {
                    "type": "identityAttribute",
                    "attributes": {
                      "name": "blastname"
                    }
                  },
                  "@demotest.com"
                ]
              }
            },
            "workerType01": {
              "type": "concat",
              "attributes": {
                "values": [
                  {
                    "type": "identityAttribute",
                    "attributes": {
                      "name": "firstname"
                    }
                  },
                  ".",
                  {
                    "type": "identityAttribute",
                    "attributes": {
                      "name": "lastname"
                    }
                  },
                  "@demotest.com"
                ]
              }
            },
            "value": "#if($workerType=='[email protected]')$workerType01#{else}$workerType#end"
          }
        }
      }
    }
  },
  "internal": false
}

Thanks,
Rohit.

Hey everyone, Thanks for your provided transform and guidance regarding different approaches here all provided transform worked but as in our requirement first valid is properly implemented, @Rohit_Sahu @KevinHarrington @Santhakumar all your solutions perfectly worked, there is no option to choose multi solution for this post. but all provided transform worked

Kudos !! @Rohit_Sahu @Santhakumar @KevinHarrington

Hey @Rohit_Sahu @KevinHarrington @Santhakumar can we add unique logic within this transform let suppose same name of person exist already then it should be appended with unique counter at the time of provisioning in this format
[email protected]
firstname.lastname@demotest.com

Try using the Username Generator transform.

3 Likes

Hey, But there also I need to use the same logic to check first for business names if not then it should pick regular names, do you think whether under username generator can we define the first valid transform to check for pairs?