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

Tasktype condition check not working in JSON

Saviynt_Savvy
Regular Contributor
Regular Contributor

Hi All,

I am creating a Ticket in the Freshservice application,
I need to put a value based on the Tasktype. Like, if the tasktype is not New Account task then I need to pass the string and a user attribute.
I am using ${task.tasktype!==3 ? 'Attribute Name'+user.customproperty5 : ''}.

But after running the Job, I couldn't provision the Ticket to "Pending Provision" state and couldn't create the Ticket.
I could see the error in logs mentioned as "Error in createNewServiceTicketcom.fasterxml.jackson.core.JsonParseException: Unrecognized token '$': was expecting ('true', 'false' or 'null')| at [Source:"

How to check the tasktype is not equal condition in Ticket JSON.
Any suggestions!

Thanks & Regards,
SaviyntSavvy

5 REPLIES 5

rushikeshvartak
All-Star
All-Star

Can you share full json.


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

Hi @rushikeshvartak 

Thank you for the response. Please take a look at the JSON below.

Create Ticket JSON:

{
"call":[
{
"name":"call1",
"connection":"acctAuth",
"url":"https://abcdefghj.freshservice.com/api/v2/tickets",
"httpMethod":"POST",
"httpParams":"{\"subject\":\"${((task.tasktype==3) && task.source=='ZERODAY') ? 'Joiner'+' '+user.firstname+' '+user.lastname:(task.tasktype==2 && task.source=='PROVRULE') ? 'Leaver'+' '+user.firstname+' '+user.lastname:''}\",\"email\":\"${task.endpoint.customproperty1}\",\"description\":\"<div><strong>Preferred Name : </strong>${user.displayname}</div></div><div><strong>Job Title : </strong>${user.title}</div><div><strong>${((task.tasktype!==3) && task.endpoint.endpointname=='Freshservice') ? 'Employee RIM-':''}</strong>${((task.tasktype!==3) && task.endpoint.endpointname=='Freshservice') ? user.username:''}</div><div><strong>Email :</strong> ${user.email}</div>\",\"priority\": 1, \"status\": 2}",
"httpHeaders":{
"contentType":"application/json",
"Authorization":"${access_token}"
},
"httpContentType":"application/json",
"ticketidPath":"ticket.id",
"unsuccessResponses":{
"message":"Failed"
}
}
]
}

Thanks & Regards,
SaviyntSavvy

{
  "call": [
    {
      "name": "call1",
      "connection": "acctAuth",
      "url": "https://abcdefghj.freshservice.com/api/v2/tickets",
      "httpMethod": "POST",
      "httpParams": "{\"subject\":\"${((task.tasktype==3) && task.source=='ZERODAY') ? 'Joiner ' + user.firstname + ' ' + user.lastname : (task.tasktype==2 && task.source=='PROVRULE') ? 'Leaver ' + user.firstname + ' ' + user.lastname : ''}\",\"email\":\"${task.endpoint.customproperty1}\",\"description\":\"<div><strong>Preferred Name : </strong>${user.displayname}</div><div><strong>Job Title : </strong>${user.title}</div><div><strong>${(task.tasktype!==3 && task.endpoint.endpointname=='Freshservice') ? 'Employee RIM-' : ''}</strong>${(task.tasktype!==3 && task.endpoint.endpointname=='Freshservice') ? user.username : ''}</div><div><strong>Email :</strong> ${user.email}</div>\",\"priority\": 1, \"status\": 2}",
      "httpHeaders": {
        "contentType": "application/json",
        "Authorization": "${access_token}"
      },
      "httpContentType": "application/json",
      "ticketidPath": "ticket.id",
      "unsuccessResponses": {
        "message": "Failed"
      }
    }
  ]
}

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

Hi @rushikeshvartak 

Still showing the same error in the LOGS.
Any other way to mention the !== condition in the JSON.

Saviynt_Savvy_0-1717444385632.png
Thanks & Regards,
SaviyntSavvy

You can use if else logic

refer sample https://docs.saviyntcloud.com/bundle/ServiceNow-v24x/page/Content/ServiceNow-as-a-Ticketing-System.h... 


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