Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

If-else condition in REST connection

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 11 2021 at 08:21 UTC

Hi Team,


We are using Saviynt V 5.5 SP3 & used REST connector for Salesforce.


We have a requirement to assign title to a user based on their Employee Type in Salseforce . For this we are trying to put if-else condition is REST connection , but its throwing syntax exception .


Can anyone please guide on how to use the condition in JSON ?


Getting error on below line - 


\"Title__c"\: \"${ if(user?.employeeType.equals('Permanent')) {(user.customproperty16)} else {(user.customproperty31)} }\" 



Thanks,

Sitarasmi

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.
15 REPLIES 15

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 11 2021 at 08:33 UTC

Hi Sitarasmi,


In which Connector JSON are you trying to use the condition?


Regards,

Sahaj

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 11 2021 at 10:27 UTC

Hi Sahaj,


In UpdateAccountJson (REST ) , we are trying to add condition.


Thanks,

Sitarsmi

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 11 2021 at 16:56 UTC

Hi Sitarsmi,


You could use a ternary operator, something like this.


\“defaultCurrency\” : \“${user?.country==‘US’?‘USD’:‘CAD’}\“,





Regards,

Avinash Chhetri

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 05:03 UTC

Hi Sita,


Please find below :
\"country\":\"${if(user.country=='India'){'IND'}else{'OTHER'}}\"


Regards,

Sahaj

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 06:41 UTC

Hi Sahaj,


We tried with both format as below, still getting syntax exception.


\"Title__c\":\"${user?.employeeType=='Permanent'?'user.customproperty16':'user.customproperty31'}\" 


and 



\"Title__c\":\"${if(user.employeeType=='Permanent'){'user.customproperty16'}else{'user.customproperty31'}}\"



Please guide 


Thanks,

Sitarasmi

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 06:43 UTC

Hello,


Would request you to provide the full json here .


Regards,

Sahaj

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 06:50 UTC

Hi Sahaj,


PFB update JSON: 



{
"dateFormat": "yyyy-mm-dd",
"responseColsToPropsMap": {},
"call": [{
"name": "Call1",
"connection": "userAuth",
"url": "https://cynergybank--fusionboc.my.salesforce.com/services/data/v49.0/sobjects/Employee__c/${userAcco... Employee Record Test').accountID}",
"httpMethod": "PATCH",
"httpParams": "{\"First_Name__c\":\"${user.firstname}\",\"Last_Name__c\":\"${user.lastname}\",\"Salutation__c\":\"${user.title}\",
\"Title__c\":\"${if(user.employeeType=='Permanent'){'user.customproperty16'}else{'user.customproperty31'}}\",
\"Business_Pillar__c\":\"${user.customproperty1}\",\"Department__c\":\"${user.customproperty2}\",\"Team__c\":\"${user.customproperty2}\",\"Mobile__c\":\"${user.customproperty7}\"}",
"httpContentType": "application/json",
"httpHeaders": {
"Authorization": "$access_token",
"accept": "application/json"
},
"successResponses": {
"statusCode": [
204
]
}
}]
}



Thanks,

Sitarasmi

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 07:02 UTC

Hello,


I could see syntax errors on Http params, please try the below :


{

"dateFormat": "yyyy-mm-dd",

"responseColsToPropsMap": {},

"call": [{

"name": "Call1",

"connection": "userAuth",

"url": "https://cynergybank--fusionboc.my.salesforce.com/services/data/v49.0/sobjects/Employee__c/${userAcco... Employee Record Test').accountID}",

"httpMethod": "PATCH",

"httpParams": "{\"First_Name__c\":\"${user.firstname}\",\"Last_Name__c\":\"${user.lastname}\",\"Salutation__c\":\"${user.title}\",\"Title__c\":\"${if(user.employeeType=='Permanent'){user.customproperty16}else{user.customproperty31}}\",\"Business_Pillar__c\":\"${user.customproperty1}\",\"Department__c\":\"${user.customproperty2}\",\"Team__c\":\"${user.customproperty2}\",\"Mobile__c\":\"${user.customproperty7}\"}",

"httpContentType": "application/json",

"httpHeaders": {

"Authorization": "$access_token",

"accept": "application/json"

},

"successResponses": {

"statusCode": [

204

]

}

}]

}

Regards,

Sahaj

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 12:08 UTC

Hi Sahaj,


Thank you for the json - We are not getting syntax error now. 


But getting below error now while updating title of the user - 


{"Call1":{"headers":null,"message":"","statusCode":null,"description":null,"status":"Failed"}}


Thanks,

Sitarasmi



This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 12:14 UTC

Hi Sitarasmi,


Please check the debuglogs for more clarity on what failed. It should show you the payload and response details.


Regards,

Sahaj

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 12:22 UTC

Hi Sahaj,


Thank you for the guidance, we will check on this.


Thanks,

Sitarasmi

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 12 2021 at 17:59 UTC

Hello Sitarasmi,


Pease refrain from providing any customer sensitive information incuding the names, url, id/password etc in the forum.

Please mask/redact the information before posting.




Regards,

Avinash Chhetri


This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 15 2021 at 04:58 UTC

Sure Avinash, will follow the same.

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on January 20 2022 at 22:03 UTC

\"Title__c\":\"<% if (user?.employeeType == 'Permanent') print \"${user.customproperty16}\" else print \"${user.customproperty31}\" %>\"

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on January 21 2022 at 09:46 UTC

try this if it still doesn't work:


\"Title_c\":\"${if(user.employeeType == 'Permanent'){return user.customproperty16}else{return user.customproperty31}}\"

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.