On Call Workflow should assign the ticket....but it doesn't

Andrew Bettcher
Kilo Sage

Hi,

I've spent the last few weeks configuring the Notify/Twilio On-Call modules. The requirement is to be able to create a rota of on-call engineers so that the person on call can be automatically identified when a certain type of incident is logged and they will receive a phone call and an SMS.

I had some issues with the Trigger Rules which were being caused by the fact that we pre-populated the Assignment Group field and had it as a Mandatory field. Apparently, the trigger rules don't like that. Anyway, it all works.

I log a ticket that meets the rules, the person who is on call according to the rota, receives a phone call which asks them to press 1 to accept the ticket (i.e. to assign it to them) or 2 to reject the ticket. In the event that the on-call engineer doesn't answer, after 15 minutes it will call the "catch all". Perfect. 

The only problem is that when the engineers presses 1, the ticket remains unassigned. The workflow activity is running (confirmed by the workflow context):

 

find_real_file.png

I added some gs.info statements to that script to ensure all of the values were correct:

var recordGr = new GlideRecord(workflow.scratchpad.recordClass);
gs.info('XXAssigned to: ' + workflow.scratchpad.participant);
gs.info('XXRecord Class: ' + workflow.scratchpad.recordClass);
gs.info('XXSys ID: ' + workflow.scratchpad.recordSysId);
if (recordGr.get(workflow.scratchpad.recordSysId) && JSUtil.nil(recordGr.getValue('assigned_to'))) {
	recordGr.assigned_to = workflow.scratchpad.participant;
	recordGr.update();
}

And they are.

If I put the log statements into the IF statements, I get nothing. So, something about that IF statement isn't working but I don't know what.

I believe it says "if there is a recordSysId and, the assigned_to field is empty then run this code". Well, there is a sys_id and the assigned_to field is empty. Furthermore, the user who it should be assigned to is in the group that the ticket is assigned to (i.e. needs to be because they are dependent). 

Does anyone have any idea why this wouldn't populate the assigned_to field or have anything I can try that I might not have though of? 

 

 

5 REPLIES 5

Abhijit4
Mega Sage

Hi,

I think the issue is with get/query method and accessing assigned to data being on the same line, could you please try below script.

var recordGr = new GlideRecord(workflow.scratchpad.recordClass);
gs.info('XXAssigned to: ' + workflow.scratchpad.participant);
gs.info('XXRecord Class: ' + workflow.scratchpad.recordClass);
gs.info('XXSys ID: ' + workflow.scratchpad.recordSysId);
if (recordGr.get(workflow.scratchpad.recordSysId)){
 if(JSUtil.nil(recordGr.getValue('assigned_to')) {
	recordGr.assigned_to = workflow.scratchpad.participant;
	recordGr.update();
}
}

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Thank you. I tried but got the same result. I'm wondering if there is something about the way I have my instance configured that is causing this. I'm thinking something similar to the assignment group being mandatory that stopped the trigger rules from running.

There is no reason why they code you provided wouldn't work (with an extra ')').

 

I get a lot of these messages in the log around the times I run the tests:

Couldn't find Crypto Module: no thrown error

I looked it up and found this KB article. I have no idea what it means.

We have SSO set up in out PROD instance but DEV is local log in only (i.e. because we can only have one instance authenticating at any given time).

 

Luiz Martins1
Tera Contributor

Hi Andrew, u good?
did u finded some way to fix or workaround, im stucked at same problem