Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

correct syntax for if-else condition in active directory connector updateaccountjson

sbiswal
New Contributor II
New Contributor II

Hello,

We have a use case where some attributes should be updated if a certain customproperty has a certain value, and other attributes should be updated if the value is different or blank.

i've tried achieving this through if else scenario, with a few different syntaxes:

SYNTAX 1) 

{${if customproperty10.equalsIgnoreCase('noupdate')
'\"givenname\": \"${if(user.firstname !=null) {user?.firstname} else {''}}\",
\"manager": "${if(managerAccount.accountID !=null) {managerAccount?.accountID} else {''}}\",'
else
'\"givenname\": \"${if(user.firstname !=null) {user?.firstname} else {''}}\",
\"sn\": \"${if(user.lastname !=null) {user?.lastname} else {''}}\",'
}}

SYNTAX 2) 

{${if(user?.customproperty10.equalsIgnoreCase('noupdate'))
"givenname": "${if(user.firstname !=null) {user?.firstname} else {''}}",
"manager": "${if(managerAccount.accountID !=null) {managerAccount?.accountID} else {''}}"}
else
{"givenname": "${if(user.firstname !=null) {user?.firstname} else {''}}",
"sn": "${if(user.lastname !=null) {user?.lastname} else {''}}",
"title": "${if(user.title !=null) {user?.title} else {''}}",
}}

Getting a similar error for both: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported)

Does someone have input on this?

Thanks in advance!

4 REPLIES 4

ParitaSavla
Saviynt Employee
Saviynt Employee

You can try something like below

"extensionAttribute8": "${if(user?.customproperty38.equals('xyz')){user.employeeid} else {'SEC_'+user.employeeid}}"

sbiswal
New Contributor II
New Contributor II

i tried this approach, but i have another doubt. if i only want the attribute to be updated if there's a null value/ or if it is not populated by a 'noupdate' value in a customproperty, what should be the syntax for that.

So far, I've tried these:

"l":"${if(user.customproperty10.isEmpty()) ${user?.city}}",

"l": "${if(user.customproperty10.equalsIgnoreCase('')) ${user?.city}}"

"l": "${if(user.customproperty10.equals('')) ${user?.city}}"

"l":"${if(user.customproperty10 ==null)${user?.city}}"

"l":"${if((user.customproperty10 === null ? '' : user.customproperty10) === user.city)(SAVIYNTNOTCHANGED) else {user?.city}}"

"department":"${if(user.customproperty10 !=null) else ${user?.departmentname}}"

"l": "${if(user?.customproperty10 != 'noupdate'))${user.city}}",

All of these are giving me error. Is there any other syntax i can use?

Thanks in advance!

Manu269
All-Star
All-Star

sample :

{${if((user?.username.startsWith('XX') || user?.username.startsWith('XY') && user?.email.contains('XX'))
'\"userprincipalname\" : \"'+user.email.toString().toLowerCase()+'\",
\"extensionattribute1\" : \"A'+user.customproperty3+'\",
\"cn\":\"'+user.lastname+'\\, '+user.firstname+'('+ user.customproperty3+')'+'\",'

else
'\"userprincipalname\" : \"'+user.email.toString().toLowerCase().substring(0,user.email.indexOf('@'))+'@<specify company name>.com\",
\"extensionattribute1\" : \"A'+user.customproperty3+'\",
\"cn\":\"'+user.lastname+'\\, '+user.firstname+'('+ user.customproperty3+')'+'\",'}}

Regards
Manish Kumar
If the response answered your query, please Accept As Solution and Kudos
.

ParitaSavla
Saviynt Employee
Saviynt Employee

Can you try with the below syntax

"l": "${if(user?.customproperty10 != 'noupdate')${user?.city}}"