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

Servicenow ticket creating based on condition

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on April 1 2022 at 15:37 UTC

Hi,


We have a use case to create service now task for users who onboarding and off boarding. So using create ticket json in service now connection we are able to create tasks for on boarding requests.

However we need to handle the offboarding as well , So is there any model json for checking task type in saviynt and dynamically add the http params (short description,description along with user details) while invoking create task.


I have tried something below , but in this case task is creating but failed to resolve user details and desired output is not coming. Any help regarding would be great help to proceed further.


"httpMethod":"POST",

         "httpParams":"{\"u_user\":\"${user.username}\",\"u_short_description\":\"${if(task?.tasktype==3){'longtext +${user.username}'} else{'long text +${user.username}'}}\",\"u_description\":\"${if(task?.tasktype==3){'long text +${user.username}'} else{'Retrive Laptop '}}\",\"u_correlation_id\":\"${task.id}\",\"u_correlation_display\":\"IGA\",\"u_category\": \"${if(task?.tasktype==3){'User onboarding'} else{'User offboarding'}}\",\"u_due_date\": \"${new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format(user.startdate)}\"}",

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

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on April 1 2022 at 16:12 UTC

Hi Sampath,


You could try using a ternary operator, An example was shared on one of the recent post shared below.


https://saviynt.freshdesk.com/a/forums/topics/43000530651




Hope it helps.



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 April 1 2022 at 19:00 UTC

Hi Avinash,


Thank you for the response.


I tried replacing the json as you suggested  but i am getting attached error. below is the json on httpParam filed.


Syntax wise i dont find any error. can you please check what is going wrong here.



"httpParams": "($task.tasktype==3)'{\"u_user\":\"${user.username}\",\"u_short_description\":\"Provision laptop for ${user.username}\",\"u_description\":\"Please build a standard mage laptop\",\"u_correlation_id\":\"${task.id}\",\"u_correlation_display\":\"IGA\",\"u_category\": \"User onboarding\",\"u_due_date\": \"${new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format(user.startdate)}\"}':'{\"u_user\":\"${user.username}\",\"u_short_description\":\"laptop for ${user.username}\",\"u_description\":\"standard Image laptop for the following user. \",\"u_correlation_id\":\"${task.id}\",\"u_correlation_display\":\"IGA\",\"u_category\": \"User onboarding\",\"u_due_date\": \"${new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format(user.startdate)}\"}'",






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 2022 at 12:17 UTC

Hi There,


can anyone here would be able to assist on how to handle conditional based json while creating ticket? I have tried above but they are not working.


Thanks

Sampath

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.

amit_krishnajit
Saviynt Employee
Saviynt Employee

Here is a working sample of httpParams based on conditions:

"httpParams": "{\"short_description\":\"Test incident creation through Saviynt\",\"comments\":\"Provisioning from Saviynt\",\"description\":\"\\\\nUsername: ${user?.username}        User Displayname: ${user?.displayname}        User Email: ${user?.email} \\\\n\\\\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}}        TaskType: ${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}} \\\\n\\\\nApplication: ${endpoint?.displayName}\",\"caller_id\":\"saviyntadmin\",\"assignment_group\":\"Help Desk\",\"priority\":\"4 - Low\",\"opened_by\":\"${if(task.requestKey!=null){com.saviynt.ecm.identitywarehouse.domain.Users.get(task?.requestedBy).email}else{'test@exaample.com'}}\",\"requested_for\":\"${user?.email}\"}"
Thanks,
Amit