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

Can I conditionally pass a parameter for a rest call in httpParams

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on April 3 2020 at 18:43 UTC

For e.g.


"httpParams":"{${if(user.employeeType!==null){if(user.employeeType !== 'Employee'){\"Organization\":'Other'}}else{'Unavailable'}}\","requested_for":"Thomas"}"

Appreciate your recommendations to pass this conditionally.

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.
18 REPLIES 18

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on April 4 2020 at 05:02 UTC

Yes, please find below a sample for the same.


"httpParams": "{\"short_description\":\"Test request creation through Saviynt\",\"comments\":\"Provisioning from Saviynt\",\"description\":\"user_name:${user.username} \\\\nuser_displayname:${user.displayname} \\\\nuser_email:${user.email} \\\\nRequestID:${if(task.requestKey!=null){task.requestKey?.processinstanceid?.substring(task.requestKey?.processinstanceid?.indexOf('.') + 1, task.requestKey?.processinstanceid?.length())}else if(task.requestKey==null){task.id}} \\\\nTaskType:${if(task.tasktype==1){'Add Access'}else if(task.tasktype==2 && (allEntitlementsValues==null || allEntitlementsValues.isEmpty() || allEntitlementsValues=='')){'Delete Account'}else if(task.tasktype==2){'Remove Access'}else if(task.tasktype==3){'New Account'}else if(task.tasktype==6){'Enable Account'}else if(task.tasktype==12){'Update Account'}else if(task.tasktype==14){'Disable Account'}else{task.tasktype}} \\\\nRequestedBy: ${if(task.requestKey!=null){com.saviynt.ecm.identitywarehouse.domain.Users.get(task?.requestedBy).email}else{''}} \\\\nApplication:${endpoint?.displayName} \\\\nAccount: ${if(task.accountName!=null){task.accountName}else{''}} \\\\nEntitlements: ${if(allEntitlementsValues==null||allEntitlementsValues.isEmpty()||allEntitlementsValues==''){''}else{allEntitlementsValues}} \\\\nComments:${if(task.requestKey!=null){''}else{''}} \",\"caller_id\":\"${if(task.requestKey!=null){com.saviynt.ecm.identitywarehouse.domain.Users.get(task?.requestedBy).email}else{''}}\",\"assignment_group\":\"Help Desk\",\"priority\":\"4 - Low\",\"requested_for\":\"${user.email}\",\"opened_by\":\"${if(task.requestKey!=null){com.saviynt.ecm.identitywarehouse.domain.Users.get(task?.requestedBy).email}else{''}}\"}",

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 April 4 2020 at 22:39 UTC

Thanks Amit, this is brilliant. My query is specific to the below one.Here I have passed the parameter inside the if condition . Is this possible.

"httpParams":"{${if(user.employeeType!==null){if(user.employeeType !== 'Employee'){\"Organization\":'Other'}}else{'Unavailable'}}\","requested_for":"Thomas"}"


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 April 6 2020 at 03:28 UTC

The above mentioned httpParams may not work

  1. It should be != instead of !==
  2. When employeeType is not equal to Employee, then it just says Unavailable instead of a key value pair
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 May 8 2020 at 10:29 UTC

Hi Amit,

Thank you for your example, I can use if-else to pass a variable from saviynt, but unable to do so with a free text string.

"short_description\":\"{if(task.tasktype==3){new joiner ${user.firstname} ${user.lastname} }

else {Leaver $ {user.firstname} ${user.lastname}}}\"

can you please help ?

Thanks and Regards,

Bitoshok

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 May 8 2020 at 10:49 UTC

Hi Bitoshok,


Could you try the following expression?

\"short_description\":\"${if(task.tasktype==3){'New Joiner '+ user.firstname + ' ' + user.lastname} else {'Leaver ' + user.firstname + ' ' + user.lastname}}\"


Thanks,

Amit

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 May 8 2020 at 15:53 UTC

Hi Amit - Thanks a lot, this worked as a charm, I edited other fields as well following the structure.

Regards,

Bitoshok

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 May 11 2020 at 13:20 UTC

Hi Amit,


I need to check whether an attribute contains a particular string ("ABC") The original string is different like "ABC 12d",

I am currently using this syntax : ${if(user.title.contains('ABC')){1}else{3}} but I guess it will not work , I need to pass the value 1 or 3 depending on whether the attribute contains "ABC", can you help me with this?


Regards,

Manisha

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 May 11 2020 at 13:52 UTC

Hi Amit,

I followed the sample which you have shared and trying to pass multiple entitlement values through CreateticketJSON.

JSON i used:

"httpParams": "{\"userid\":\"$user.systemUserName\",\"RequestID\":\"${task.requestKey?.processinstanceid?.substring(task.requestKey?.processinstanceid?.indexOf('.') + 1, task.requestKey?.processinstanceid?.length())}\",\"application\": \"$task.endpoint.displayName\",\"tasks\": \"${allEntitlementsValues}\",\"comments\": \"${task.comments}\"}"


- If raising a request for one entitlement then it works fine if it is more than one. Then it throws error.


Could you please confirm if "allEntitlementsValues" can be used to pass more than 1 entitlement values ? or do we have any other object variable?


Regards,

Rohit

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 May 12 2020 at 07:25 UTC

Hi Manisha,


The following expression should workout for you:

\"short_description\":\"${if(user.username.contains('EMP')){'Employee provisioning'}else{'Test request creation through Saviynt'}}\"


You can further add conditions to check not null, not empty, etc.


Thanks,

Amit

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 May 12 2020 at 07:27 UTC

Hi Rohit,


allEntitlementsValues should hold all entitlements requested for the specific Endpoint. What is the error that you get in case of multiple entitlements?


Thanks,

Amit

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 May 12 2020 at 07:45 UTC

Hi Amit,


Below is the error message in log:

"tasks": "${allEntitlementsValues}"}}

2020-05-12 07:34:27,505 [quartzScheduler_Worker-1] DEBUG rest.RestProvisioningService - Error in createNewServiceTicketcom.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value


When i try to escape :(colon) , \n(new line char) which i thing is causing an issue. then it throws error for next letter. for e.g. 'A' . FYI, this is first letter of ADD : memeberOf : Ent.

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 May 12 2020 at 08:05 UTC

For your reference,

the format in which it is passing the values is:

"tasks": "ADD :: memberOf : (Ent1 Value),

ADD :: memberOf : (Ent2 Value)"}};

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 May 15 2020 at 18:00 UTC

Hi team / Amit,


When I try to pass assignment group value stored in an endpoint custom property , it works :

\"assignment_group\":\"${if(task.tasktype==3){task.endpoint.customproperty6}else {task.endpoint.customproperty7}}\"

But if I try to hard code the value in the JSON itself, it says error in getting ticket number and do not generate a ticket :

\"assignment_group\":\"${if(user.city==Charlottesville){ERP_JCORE}else {Assets_Projects}}

\"assignment_group\":\"${if(user.city=='Charlottesville'){ERP_JCORE}else {Assets_Projects}}

\"assignment_group\":\"${if(user.city=='Charlottesville'){'ERP_JCORE'}else {'Assets_Projects'}}

None of the above works, can you please help ?


Regards,

Bitoshok

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 May 18 2020 at 10:12 UTC

Hi Rohit,

For adding new line charater, you may want to escape the '\' in '\n'. Try the following may be : \"description\":\"user_name:${user.username} \\\\nuser_displayname:${user.displayname}\"



Hi Bitoshok,

What is ERP_JCODE or Assets_Projects? Are these name of dynamic attributes or are these static strings? If these are static strings, you may want to try the following: \"assignment_group\":\"${if(user.city=='Charlottesville'){'ERP_JCORE'}else {'Assets_Projects'}}\". Also, I hope the city value is not null for the user.


Thanks,

Amit


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 February 3 2022 at 05:26 UTC

Hi Amit,


I am raising the request for Enterprise Role.

I am using below variable for createTicket :

${allEntitlementsValues}


It is printing the role details with associated entitlement and action to be performed (i.e. Add or Remove)


I am looking for an option where I can extract the Role Details separately and associated entitlement separately. Is this possible? Please share a sample? Kindly note in a request multiple role would be requested?


Also is there a way to extract the role metadata information also for requested role?

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 February 4 2022 at 05:37 UTC

Hi Manish,


For role metadata, you may use the following:

${task?.assignedFromRole} 

${task?.assignedFromRole?.customproperty1}


For entitlements, you will have to rely on the ${allEntitlementsValues}.


Thanks,

Amit 

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 February 4 2022 at 08:40 UTC

Hi Amit,


Many thanks for the update.


I have a problem here :

1. When I am making request for more than 1 role in same request then it is not printing both the role name.

It is printing only role from list.


2. Also, I am looking for an option to print start date and end date which was provided as part of request. Can you help me how can we extract all these details


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 February 4 2022 at 11:43 UTC

Hi Amit,


If possible can you also help us in sharing how can we pass the Saviynt ARS Page URL as a variable in createTicketJson?


Thanks

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.