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

Use Case

Consider the following JSON example, which involves assigning different access groups based on a user's EmployeeClass.

The use case is as follows:
- IF user.EmployeeClass is one of ('A1', 'A2', 'A3', 'A4', 'A5'), THEN assign accessGroup /292 ELSE       assign accessGroup /291

which can be done with either of these APIs:
 
 \"accessGroups\":[{\"accessGroup\":{\"href\":\"https://xx.xx.xxx.xx:8904/api/access_groups/292\"}}
 
OR
 
\"accessGroups\":[{\"accessGroup\":{\"href\":\"https://xx.xx.xxx.xx:8904/api/access_groups/291\"}}] 
 

Pre-requisites

Ensure that the JSON is properly configured in the REST connector.

Applicable Version(s)

This solution is applicable to all versions.

Logs

If you encounter the following parsing error in the logs:
```
2022-03-29/00:01:02.428 [{}] [quartzScheduler_Worker-4] ERROR rest.RestProvisioningService - Error in createNewUser::
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('a' (code 97)): was expecting comma to separate Object entries
at [Source: {"@Fortescue ID":"${user.employeeid}","firstName": "${user.firstname}","lastName":"${user.lastname}","authorised": "true","division":{"href":"https://xx.xx.xx.xx:8904/api/divisions/2"},"accessGroups": "${if(user.employeeclass=='A1'||user.employeeclass=='A2'||user.employeeclass=='A3'||user.employeeclass=='A4'||user.employeeclass=='A5')? [{"accessGroup":{"href":"https://xx.xx.xx.xx:8904/api/access_groups/292"}}] else [{"accessGroup":{"href":"https://xx.xx.xx.xx:8904/api/access_groups/291"}}]}"}; line: 1, column: 344]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)

Solution

The Saviynt REST connector supports the use of if-else conditions as ternary operators.
Refer to the example below:

```
{
"accessGroups": "${user.employeeclass=='A1'||user.employeeclass=='A2'||user.employeeclass=='A3'||user.employeeclass=='A4'||user.employeeclass=='A5' ? [{\"accessGroup\":{\"href\":\"https://xx.xx.xx.xx:8904/api/access_groups/292\"}}] : [{\"accessGroup\":{\"href\":\"https://xx.xx.xx.xx:8904/api/access_groups/291\"}}]}"
}

```

Note: Please note that the if-else condition does not support array lists. 

 

References
https://docs.saviyntcloud.com/bundle/REST-v23x/page/Content/Developers-Handbook.htm 

Comments
anuragG
New Contributor III
New Contributor III

Can i send string value as per If else condition in REST connector only?

Version history
Last update:
‎06/23/2023 12:11 AM
Updated by:
Contributors