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 as tickeing system with if-else condition

SumathiSomala
All-Star
All-Star

Hi team,

We have onboarded ServiceNow as a Ticketing System and created REQ through CreateTicketJSON. 

REQ is created successfully (attached the image).

I have used if-else condition in description. but my logic also printing as string. Attaching the createtickenjson.

Createticket json:
{
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://dev108160.service-now.com/api/now/table/sc_request",
"httpMethod": "POST",
"httpParams": "{\"opened_by\":\"${user.username}\",\"requested_for\":\"${user.username}\",\"short_description\":\"This request has been created from Saviynt Security Manager IAM system\",\"RequestID\":\"${if(task.requestKey!=null){task.requestKey?.processinstanceid?.substring(task.requestKey?.processinstanceid?.indexOf('.') + 1, task.requestKey?.processinstanceid?.length())}else if(task.requestKey==null){task.id}}\",\"description\":\"${if(task.tasktype==1 || task.tasktype==3){'Complete this request to create account for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application along with access '+${allEntitlementsValues}}else if(task.tasktype==2 && (allEntitlementsValues==null || allEntitlementsValues.isEmpty() || allEntitlementsValues=='')){'Complete this request to remove account for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application as all accesses removed'}else if(task.tasktype==2 && task.source=='REQUEST'){'Complete this request to remove access for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application with access '+${allEntitlementsValues}}else if (task.source=='CERTIFICATION' && task.tasktype==2){'This request is to remove access as part User Manager Certification for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application with access '+${allEntitlementsValues}}else {'Complete this request to remove account for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application along with access '+${allEntitlementsValues}}}\",\"application\":\"${task.endpoint?.displayName}\"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath": "result.number",
"successResponses": {
"statusCode": [
200,
201
]
}
}
]
}

 

SumathiSomala_0-1690549086929.png

 

Regards,
Sumathi Somala
If this reply answered your question, please Accept As Solution and give Kudos.
5 REPLIES 5

armaanzahir
Valued Contributor
Valued Contributor

Hi @SumathiSomala ,

 

You've already defined the ${ at the beginning of the description value, hence no need to add ${} in the allEntitlementsValues variable.

 

${if(task.tasktype==1 || task.tasktype==3){'Complete this request to create account for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application along with access '+allEntitlementsValues}else if(task.tasktype==2 && (allEntitlementsValues==null || allEntitlementsValues.isEmpty() || allEntitlementsValues=='')){'Complete this request to remove account for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application as all accesses removed'}else if(task.tasktype==2 && task.source=='REQUEST'){'Complete this request to remove access for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application with access '+allEntitlementsValues}else if (task.source=='CERTIFICATION' && task.tasktype==2){'This request is to remove access as part User Manager Certification for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application with access '+allEntitlementsValues}else {'Complete this request to remove account for ' +user.firstname+' ' +user.lastname +'in ' +task.endpoint?.displayName +' application along with access '+allEntitlementsValues}}

 

Can you try the above value for description field and check? 

 

Thanks,

Armaan

Regards,
Md Armaan Zahir

SumathiSomala
All-Star
All-Star

Thank you @armaanzahir 

I tried this, description field is printing as expected.

Also pasting my Ticketstatus json

Can you please check my  ticketStatusValue and disContinueStatusValue and pls confirm that  provided correct or not


{
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://XXXXX.service-now.com/api/now/table/sc_request?sysparm_query=number=${ticketID}&sysparm_limi...",
"httpMethod": "GET",
"httpHeaders": {
"Authorization": "${access_token}" },
"httpContentType": "application/json",
"ticketStatusPath": "result[0].state",
"ticketStatusValue":[
"Closed Complete",
"closed",
"CLOSED",
"Closed"
],
"disContinueStatusValue":[
"Closed Incomplete",
"CLOSED Cancelled",
"CLOSED Rejected",
"CLOSED Skipped"
],
"successResponses": {"statusCode":[200,201]}
}
]
}

 

Regards,
Sumathi Somala
If this reply answered your question, please Accept As Solution and give Kudos.

looks correct 

{
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://dev.service-now.com/api/now/table/sc_request?sysparm_query=number=${ticketID}&sysparm_limit=1&sysparm_display_value=true",
"httpMethod": "GET",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketStatusPath": "result[0].state",
"ticketStatusValue": [
"Closed Complete",
"closed",
"CLOSED",
"Closed"
],
"disContinueStatusValue": [
"Closed Incomplete",
"closed incomplete",
"CLOSED INCOMPLETE"
],
"successResponses": [
{}
]
}
]
}

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

thank for the quick response @rushikeshvartak 

can't we use below as disContinueStatusValue?

"CLOSED Cancelled",
"CLOSED Rejected",
"CLOSED Skipped"

Regards,
Sumathi Somala
If this reply answered your question, please Accept As Solution and give Kudos.

If those are valid coming from responses then you can


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