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 REST connector JSON.

Rajatlm10
New Contributor III
New Contributor III

Hi , 

I am using the below if else syntax in REST connector JSOn. even though the task are getting completed but the correct values in condition are not getting picked up. 

Can anyone validate if i am doing it the right way or not ?

{
"call": [
{
"name": "Country",
"connection": "acctAuth",
"url": "https://xyz/Users/${account.customproperty5}",
"httpMethod": "PATCH",
"httpParams": "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":[{\"op\": \"add\",\"path\":\"urn:ietf:params:scim:schemas:extension:spend:2.0:Role:roles\",\"value\":[{\"roleName\":\"${requestAccessAttributes?.get('Rolename')}\",\"roleGroups\":[\"if(${${task.entitlement_valueKey.entitlement_value}}=='AUSTRIA') {'[AT-480]'} else if(${task.entitlement_valueKey.entitlement_value}=='Belgium'){'[BE-140]'} else if(${task.entitlement_valueKey.entitlement_value}=='Canada'){'[CA-002]'} else if(${task.entitlement_valueKey.entitlement_value}=='Denmark'){'[DK-200]'} else if(${task.entitlement_valueKey.entitlement_value}=='Finland'){'[FI-230]'} else if(${task.entitlement_valueKey.entitlement_value}=='France'){'[FR-130]'} else if(${task.entitlement_valueKey.entitlement_value}=='Germany'){'[DE-060]'} else if(${task.entitlement_valueKey.entitlement_value}=='Greece'){'[GR-270]'} else if(${task.entitlement_valueKey.entitlement_value}=='Ireland'){'[IE-120]'} else if(${task.entitlement_valueKey.entitlement_value}=='Italy'){'[IT-150]'} else if(${task.entitlement_valueKey.entitlement_value}=='Mexico'){'[MX-170]'} else if(${task.entitlement_valueKey.entitlement_value}=='NL-Venray'){'[NL-070]'} else if(${task.entitlement_valueKey.entitlement_value}=='NL-Holland'){'[NL-071]'} else if(${task.entitlement_valueKey.entitlement_value}=='Norway'){'[NO-080]'} else if(${task.entitlement_valueKey.entitlement_value}=='Portugal'){'[PT-050]'} else if(${task.entitlement_valueKey.entitlement_value}=='Spain'){'[ES-040]'} else if(${task.entitlement_valueKey.entitlement_value}=='Sweden'){'[SE-090]'} else if(${task.entitlement_valueKey.entitlement_value}=='Switzerland'){'[CH-470]'} else if(${task.entitlement_valueKey.entitlement_value}=='United Kingdom'){'[UK-010]'} else if(${task.entitlement_valueKey.entitlement_value}=='US-XBS'){'[US-005]'} else if(${task.entitlement_valueKey.entitlement_value}=='Isreal'){'[IL-310]'} else if(${task.entitlement_valueKey.entitlement_value}=='Malaysia'){'[MY-320]'} else if(${task.entitlement_valueKey.entitlement_value}=='Japan'){'[JP-100]'} else if(${task.entitlement_valueKey.entitlement_value}=='S korea'){'[KR-530]'} else if(${task.entitlement_valueKey.entitlement_value}=='China'){'[CN-340]'} else if(${task.entitlement_valueKey.entitlement_value}=='Hong kong'){'[HK-370]'} \"]}]}]}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,
201
]
}
}
]
}

2 REPLIES 2

adriencosson
Valued Contributor
Valued Contributor

Hi @Rajatlm10 ,

The "IF / ELSE" condition must be surrounded by ${ } and all the logic must be contained inside, but you then don't need to use the same to surround the task.entitlement_value.entitlement_value object.

Please find an example below (simplified) :

${if (task.entitlement_valuekey.entitlement_value=='AUSTRIA') {'[AT-480]'} else if if(task.entitlement_valueKey.entitlement_value=='Belgium'){'[BE-140]'} else if () {} ... else {''} }

 Hope this helps.

Regards,
Adrien COSSON

rushikeshvartak
All-Star
All-Star
{
"call": [
{
"name": "Country",
"connection": "acctAuth",
"url": "https://xyz/Users/${account.customproperty5}",
"httpMethod": "PATCH",
"httpParams": "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":[{\"op\": \"add\",\"path\":\"urn:ietf:params:scim:schemas:extension:spend:2.0:Role:roles\",\"value\":[{\"roleName\":\"${requestAccessAttributes?.get('Rolename')}\",\"roleGroups\":[\"${if (task.entitlement_valueKey.entitlement_value == 'AUSTRIA') {'[AT-480]'} else if (task.entitlement_valueKey.entitlement_value == 'Belgium') {'[BE-140]'} else if (task.entitlement_valueKey.entitlement_value == 'Canada') {'[CA-002]'} else if (task.entitlement_valueKey.entitlement_value == 'Denmark') {'[DK-200]'} else if (task.entitlement_valueKey.entitlement_value == 'Finland') {'[FI-230]'} else if (task.entitlement_valueKey.entitlement_value == 'France') {'[FR-130]'} else if (task.entitlement_valueKey.entitlement_value == 'Germany') {'[DE-060]'} else if (task.entitlement_valueKey.entitlement_value == 'Greece') {'[GR-270]'} else if (task.entitlement_valueKey.entitlement_value == 'Ireland') {'[IE-120]'} else if (task.entitlement_valueKey.entitlement_value == 'Italy') {'[IT-150]'} else if (task.entitlement_valueKey.entitlement_value == 'Mexico') {'[MX-170]'} else if (task.entitlement_valueKey.entitlement_value == 'NL-Venray') {'[NL-070]'} else if (task.entitlement_valueKey.entitlement_value == 'NL-Holland') {'[NL-071]'} else if (task.entitlement_valueKey.entitlement_value == 'Norway') {'[NO-080]'} else if (task.entitlement_valueKey.entitlement_value == 'Portugal') {'[PT-050]'} else if (task.entitlement_valueKey.entitlement_value == 'Spain') {'[ES-040]'} else if (task.entitlement_valueKey.entitlement_value == 'Sweden') {'[SE-090]'} else if (task.entitlement_valueKey.entitlement_value == 'Switzerland') {'[CH-470]'} else if (task.entitlement_valueKey.entitlement_value == 'United Kingdom') {'[UK-010]'} else if (task.entitlement_valueKey.entitlement_value == 'US-XBS') {'[US-005]'} else if (task.entitlement_valueKey.entitlement_value == 'Isreal') {'[IL-310]'} else if (task.entitlement_valueKey.entitlement_value == 'Malaysia') {'[MY-320]'} else if (task.entitlement_valueKey.entitlement_value == 'Japan') {'[JP-100]'} else if (task.entitlement_valueKey.entitlement_value == 'S korea') {'[KR-530]'} else if (task.entitlement_valueKey.entitlement_value == 'China') {'[CN-340]'} else if (task.entitlement_valueKey.entitlement_value == 'Hong kong') {'[HK-370]'} else {''}}]\"]}]}]}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,
201
]
}
}
]
}

Regards,
Rushikesh Vartak
If you find this response useful, kindly consider selecting 'Accept As Solution' and clicking on the 'Kudos' button.