Hello developer community,
I have been working on enhancing a termination workflow to check for an existing termination ticket in our ITSM and if one does not exist to create one for them.
Limitations/caveats:
- The ITSM API only allows me to perform a search based on the ticket offering (Termination Request), ticket status (Open,Pending,Submitted), the submitter/affected user(manager), and date logged(no way to dynamically get dates in the workflows yet.).
*Manager may have multiple termination request submitted for different staff.
My Ask:
How can I take the response below and do a compare on it to ensure there is or is not an existing ticket for john smith in this case? In my example two tickets were returned for the same manager for two different users. I’m assuming the way I am declaring the variable in not proper syntax due to the structure of the response.
Response from ITSM:
{
"checkForExistingTerminationRequest": {
"body": [
{
"affectedUserEmail": "Manager email",
"affectedUserName": "Manager First and last name",
"customFields": [
{
"contactUserValue": {
"email": "[email protected]",
"emailAddress": "[email protected]",
"name": "James Walker",
"username": "Username"
},
"customFieldShortCode": "TERMINATED USER",
"systemLookupValue": {
"email": "[email protected]",
"emailAddress": "[email protected]",
"name": "James Walker",
"shortCode": "jamesusername"
},
"systemLookupValueShortCode": "jamesusername"
}
],
"createddate": "2023-04-20T14:18:09.117-05:00",
"ticketstatus": "OPEN"
},
{
"affectedUserEmail": "Manager email",
"affectedUserName": "Manager First and last name",
"customFields": [
{
"contactUserValue": {
"email": "[email protected]",
"emailAddress": "[email protected]",
"name": "John Smith",
"username": "Username"
},
"customFieldShortCode": "TERMINATED USER",
"systemLookupValue": {
"email": "[email protected]",
"emailAddress": "[email protected]",
"name": "John Smith",
"shortCode": "Johnusername"
},
"systemLookupValueShortCode": "johnusername"
}
],
"createddate": "2023-04-13T14:18:09.117-05:00",
"ticketstatus": "OPEN"
}
],
"headers": {},
"responseTime": "1.335754 seconds",
"statusCode": 200
}
}
What I have attempted:
-
Using Compare Strings to evaluate $.checkForExistingTerminationRequest.body.customFields.systemLookupValueShortCode Equals $.getIdentity.username
-
Using Compare Strings to evaluate
$.checkForExistingTerminationRequest.body.customFields.systemLookupValueShortCode Contains $.getIdentity.username -
Using Verify Data Type
Verify that $.checkForExistingTerminationRequest.body Exists
(Verify Data Type sort of works but falls down if there are multiple tickets for employees that are not the one terminating)