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

If-Else condition for Tasktype in Create Ticket JSON

Saviynt_Savvy
Regular Contributor
Regular Contributor

Hi, 
The below JSON is not able to generate the ticket for Jira Ticketing System.
As the "tasktype=2" for both the "Remove Access" and "Remove Account", how to mention the condition using 'If-Else' to check the 'Tasktype' and set the 'summary' field of Jira Ticket.

There is issue with the 'ID' field in the JSON, the "user.customproperty8" field is working fine.

In the JSON, I am checking for the "Remove Access" condition only. But I need to check for "Remove Account" type also. How to do the condition check in the query in the JSON below:


{
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "https://xxxxxx.net/rest/api/3/issue",
"httpMethod": "POST",
"httpParams": "{\"fields\": {\"project\":{\"key\":\"SP\"},\"summary\":\"${if(task.tasktype==1){'Add Access Ticket'}else if(task.tasktype==2 && task.entitlement_valuekey!==null){'Remove Access'}else if(task.tasktype==3){'Add Account Ticket'}else{'unknowtask'}}\",\"issuetype\": {\"name\": \"Task\"},\"reporter\":{\"id\": \"${user.customproperty8}\"}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath": "id",
"unsuccessResponses": {
"message": "Failed"
}
}
]
}

5 REPLIES 5

SumathiSomala
All-Star
All-Star

@Saviynt_Savvy Seem to be issue is with ticketidPath.

Try below mapping

"ticketidPath": "result.number",

 

Also attached the sample JSON with if -else condition.

If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

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

Hi Sumathi,
Thanks for response.
There is no issue with the 'ticketidPath' and it is the JIRA Ticketing System we are using, not the Service Now.
If I make simple condition check, like... "if (task.tasktype==2){'Remove Account'}", then it is working fine. 

@Saviynt_Savvy can you share postman response?

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

Hi @SumathiSomala ,
Please find the Postman Response below:

{
    "id""10084",
    "key""JI-31",
}

Please share the error logs and you can use my attached json as a reference for if -else condition.

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