and more in a single search tool across platforms. Read the announcement here. |
04/12/2022 01:19 PM
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
Solved! Go to Solution.
04/12/2022 02:59 PM
Hi Sitarasmi,
In which Connector JSON are you trying to use the condition?
Regards,
Sahaj
04/12/2022 02:59 PM
Hi Sahaj,
In UpdateAccountJson (REST ) , we are trying to add condition.
Thanks,
Sitarsmi
04/12/2022 02:59 PM
Hi Sitarsmi,
You could use a ternary operator, something like this.
\“defaultCurrency\” : \“${user?.country==‘US’?‘USD’:‘CAD’}\“,
Regards,
Avinash Chhetri
04/12/2022 02:59 PM
Hi Sita,
Please find below :
\"country\":\"${if(user.country=='India'){'IND'}else{'OTHER'}}\"
Regards,
Sahaj
04/12/2022 02:59 PM
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
04/12/2022 02:59 PM
Hello,
Would request you to provide the full json here .
Regards,
Sahaj
04/12/2022 02:59 PM
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
04/12/2022 02:59 PM
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
04/12/2022 02:59 PM
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
04/12/2022 02:59 PM
Hi Sitarasmi,
Please check the debuglogs for more clarity on what failed. It should show you the payload and response details.
Regards,
Sahaj
04/12/2022 02:59 PM
Hi Sahaj,
Thank you for the guidance, we will check on this.
Thanks,
Sitarasmi
04/12/2022 02:59 PM
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
04/12/2022 02:59 PM
Sure Avinash, will follow the same.
04/12/2022 02:59 PM
\"Title__c\":\"<% if (user?.employeeType == 'Permanent') print \"${user.customproperty16}\" else print \"${user.customproperty31}\" %>\"
04/12/2022 02:59 PM
try this if it still doesn't work:
\"Title_c\":\"${if(user.employeeType == 'Permanent'){return user.customproperty16}else{return user.customproperty31}}\"