03/09/2023 03:18 AM
Hi All.
Its a REST based application.
Requirement: If user has email in saviynt then we need push that email to target, if not then need push sample email like "username@dummyemail.com" to target. Email is one of the mandatory field in create account JSON.
I have tried with below syntax, but its not working.
\"${if(user?.email!=null) {user.email} else {{user.username}'@dummyemail.com'}}\"
Please review this and provide your suggestion on this,
Solved! Go to Solution.
03/09/2023 04:06 AM
Thank you for contacting the Saviynt forums.
Kindly try the below syntax and let us know if further assistance is needed from our end
\"${user?.email ? user.email : user.username + '@dummyemail.com'}\"
Here, the ternary operator checks if the user has an email address (user?.email). If yes, then it uses the email address (user.email). If not, it uses the username and appends the @dummyemail.com domain to create a sample email address.
Also, make sure that the JSON payload contains the correct field name for email address and that the syntax for the entire JSON payload is correct.
03/09/2023 05:09 AM
@DixshantValecha Thank you for help. syntax is working as expected.
03/09/2023 11:43 PM
Thanks for your update we will mark this as a solution.
03/13/2023 05:33 AM
@DixshantValecha Now client team changed sample email requirement to: firstname.lastname.username@dummyemail.com. I have updated existing ternary operator as below and its not working.
\"email\":\"${user?.email ? user.email : (user.firstename).(user.lastname).(user.username) + '@dummyemail.com'}\",
Please check this syntax and help me on this issue resolution
03/13/2023 05:50 AM
Thank you for your inquiry regarding the syntax error you are experiencing with the updated ternary operator for the email field.
Please try modifying the operator as follows:
""email":"${user?.email ? user.email : user.firstname + '.' + user.lastname + '.' + user.username + '@dummyemail.com'}","
This should concatenate the user's first name, last name, and username with the domain name to create the email address in the format you require.
If you continue to experience difficulties, please let us know
03/24/2023 04:55 AM
Hi @Rajesh_IAM
Let us know if the below solution worked for you
Please try modifying the operator as follows:
""email":"${user?.email ? user.email : user.firstname + '.' + user.lastname + '.' + user.username + '@dummyemail.com'}","
This should concatenate the user's first name, last name, and username with the domain name to create the email address in the format you require.