Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

REST; Error while using If-Else in CreateAccountJson

vivekrajan
New Contributor II
New Contributor II

Hi Team,

I want to pass values like "/api/sample/17", "/api/sample/16", "/api/sample/15", "/api/sample/14"

based on If-Else condition in CreateAccount JSON.

When I try IF-ELSE condition, it throws error like - "An account with the user field value of '${user.username}' already exists". 

When I do not use IF-ELSE condition, it successfully passes the values without any issue.

Attaching JSON and logs for reference. please let me know a solution for this.

4 REPLIES 4

vivekrajan
New Contributor II
New Contributor II
 

@vivekrajan Try below

\"${if(user.departmentname == 'Avaya Operations'){'/api/sample/17'} else{'/api/sample/10'}}\"


\"${if(user.departmentname.equals('Avaya Operations')){'/api/sample/17'} else{'/api/sample/10'}}\"

 

 

Regards,
Sumathi Somala

If this reply answered your question, please Accept As Solution and give Kudos.

armaanzahir
Valued Contributor
Valued Contributor

@vivekrajan 

 

Have you tried using the ternary operator?

${(user.departmentname=='Avaya Operations')?'/api/sample/17':'/api/sample/10'}

Check if this works for you.

 

Regards,
Md Armaan Zahir

vivekrajan
New Contributor II
New Contributor II

Thanks Sumathi and Armaan, I found the logical mistake after comparing your sample code.