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 not working in CreateTicket JSON for REST Connection

PRATYUSH1
New Contributor III
New Contributor III

We are trying to add the if else condition for the Subject line in our ticketing tool. We are trying to change the subject line based on the action taken in the ARS page.

The JSON we are using is:

{
   "call":[
      {
         "name":"call1",
         "connection":"acctAuth",
         "url":"xxxxxx",
         "httpMethod":"POST",
         "httpParams":"{\"ticket\":[{\"eeid_c\":\"${if(task?.tasktype==3){user.employeeid} else{'Dummy'}}\",\"Subject\":\"${if(task?.tasktype==3){endpoint?.customproperty1} else{endpoint?.customproperty2}} ${user.firstname} ${user.lastname}\", \"Description\":\"${endpoint?.customproperty2}\", \"Cust_Type_c\":\"${endpoint?.customproperty3}\", \"Item_c\":\"${endpoint?.customproperty4}\", \"Cust_Category_c\":\"${endpoint?.customproperty5}\"}]}",
         "httpHeaders":{
            "Authorization":"${access_token}",
            "Accept":"application/json"
         },
         "httpContentType":"application/json",
         "ticketidPath":"CaseNumber",
         "successResponses":{
            "statusCode":[
               200,
               201
            ]
         }
      }
   ]
}

 

This is throwing error and we are unable to find out why. Please help us to resolve this issue.

2 REPLIES 2

Darshanjain
Saviynt Employee
Saviynt Employee

Hi @PRATYUSH1 

Instead of using if else, try to use the ternary operators in createticket json, 

Example for one expression for above would be- 

${(task.tasktype == 3) ? user.employeeid : 'Dummy'}

 

Thanks

Darshan

Manu269
All-Star
All-Star

@PRATYUSH1 please refer below sample :

{\"short_description\":\"${if(task.source=='PROVRULE' && task?.tasktype==14){'[NO ACTION REQUIRED]:'} else if(task.tasktype==14){'[NO ACTION REQUIRED]:'} else if(task.requestKey?.requesttype==3 || task.requestKey?.requesttype==11 && task.tasktype==3){''}else if(task.tasktype==2 && (allEntitlementsValues==null || allEntitlementsValues.isEmpty() || allEntitlementsValues=='')){''}else if(task.source=='PROVRULE' && task?.tasktype==2){''}else if(task.tasktype==2){''}else if(task.requestKey?.requesttype != 3 && task?.tasktype==1){''}else if(task.tasktype==6){''}else if(task.tasktype==12){''}else{task.tasktype}}

Regards
Manish Kumar
If the response answered your query, please Accept As Solution and Kudos
.