Click HERE to see how Saviynt Intelligence is transforming the industry. |
03/21/2024 03:13 PM - last edited on 03/21/2024 10:22 PM by Sunil
Hi Team,
We have a use case to skip ticket creation if the task source is request. We tried different JSON configurations to fail service ticket creation. Here are the different Create Ticket JSON configurations we have tried
Option -1 – Create Ticket JSON
{ "ticketidPath": "call2.message.result.number", "call": [ { "name": "call1", "connection": "acctAuth", "url": https://dev.service-now.com/api/now/v1/table/sc_request , "httpMethod": "POST", "httpParams": "{}", "httpHeaders": { "Authorization": "${access_token}" }, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200, 201 ] } }, { "name": "call2", "connection": "acctAuth", "url": https://dev.service-now.com/api/now/v1/table/sc_req_item , "httpMethod": "POST", "httpParams": "{}", "httpHeaders": { "Authorization": "${access_token}" }, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200, 201 ] } } ] } |
Result 1- The ticket has been created with blank/default values. So, it looks like somehow, we need to throw an exception from the JSON in case the task source is “Request”.
Option 2- We tried to put if condition on Access token
"Authorization": "${if(task.requestKey!=null){{access_token}}}" OR "Authorization": "${if(arsTasks.source.equals('REQUEST')){{access_token}}}"
Result 2- Tickets for both scenarios were not created with the following exception-
Error in getting Ticket Number. Response: {"call1":{"headers":null,"message":"","statusCode":null,"description":null,"status":"Failed"},"call2":{"message":"Unrecognized character escape (CTRL-CHAR, code 10)\n at [Source: {\
Option 3- We tried to put if condition at the start of Create Ticket JSON
{ "if": { "$(task.requestKey)": null}, "then": { "ticketidPath": "call2.message.result.number", "call": [ { "name": "call1", "connection": "acctAuth", "url": https://dev.service-now.com/api/now/v1/table/sc_request , "httpMethod": "POST", "httpParams": "{\"opened_by\":\"svc_syt01dev\",\"requested_for\":\"${user.firstname} ${user.lastname}\",\"assignment_group\":\"${if(task.endpoint?.customproperty1 == 'LearningandDevelopment'){ 'Learning and Development' } else if(task.endpoint?.customproperty1 == 'ITServiceDesk'){ 'IT Service Desk' } else if(task.endpoint?.customproperty1 == 'FieldServices'){ 'Field Services' } else if(task.endpoint?.customproperty1 == 'PhysicalSecurity'){ 'Physical Security' } else { 'IAM' }}\",\"short_description\":\"ITServiceDesk\",\"description\":\"ITServiceDesk\",\"assigned_to\":\"${task.endpoint?.ownerkey}\"}", "httpHeaders": { "Authorization": "${access_token}" }, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200, 201 ] } }, { "name": "call2", "connection": "acctAuth", "url": https://dev.service-now.com/api/now/v1/table/sc_req_item , "httpMethod": "POST", "httpParams": "{\"opened_by\":\"svc_syt01dev\",\"cat_item\":\"IT Security Birthright Access \",\"u_subcategory\":\"Identity Management\",\"request\":\"${response.call1.message.result.number}\",\"requested_for\":\"${user.firstname} ${user.lastname}\",\"assignment_group\":\"${if(task.endpoint?.customproperty1 == 'LearningandDevelopment'){ 'Learning and Development' } else if(task.endpoint?.customproperty1 == 'ITServiceDesk'){ 'IT Service Desk' } else if(task.endpoint?.customproperty1 == 'FieldServices'){ 'Field Services' } else if(task.endpoint?.customproperty1 == 'PhysicalSecurity'){ 'Physical Security' } else { 'IAM' }}\",\"description\":\"ITServiceDesk\"}", "httpHeaders": { "Authorization": "${access_token}" }, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200, 201 ] } } ] } } |
Result 3- Save and Test connection failed.
Is there a way to throw an exception to make sure ticket creation is failed if task source is request?
[This message has been edited by moderator to disable url hyperlink]
03/21/2024 06:35 PM
use callCondition
"callCondition": "${arstasksObj?.source == 'REQUEST'}",