Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

On-Call Workflow Started from Business Rule, Task Not Assigned to Primary On-Call User

NishmithaS
Tera Contributor

Hi All

I copied the OOB On-Call  Assign workflow and added a custom Run Script after the assignment activity to send notifications to the primary and secondary on-call users
var rota = new OnCallRotation();
var groupId = current.assignment_group.toString();
var escalatees = rota.getEscalatees(groupId, null, null, new GlideDateTime(), current);

var ids = [];
for (var i = 0; i < escalatees.length; i++) {
    var e = escalatees[i];
    if (e.order > 2) continue;

    if (e.userId)
        ids.push(e.userId);

    if (e.userIds)
        ids = ids.concat(e.userIds);
}

ids = new ArrayUtil().unique(ids);

if (ids.length)
    gs.eventQueue('oncall.primary_secondary.notify', current, ids.join(','), '');​

 

The Assignment Group is populated during task creation itself, so the standard On-Call Trigger Rule does not execute in my scenario and started it from an After Insert Business Rule.
Business Rule Configuration

Table: sc_task
When: After
Insert: true
Condition: Assignment Group is Database
(function executeRule(current, previous) {

    var workflowSysId = '67e60e32c3634f503fe1befdd40131e1';

    var vars = {};
    vars.assignment_group = current.assignment_group;

    var wf = new Workflow();
    wf.startFlow(workflowSysId, current, current.operation(), vars);

})(current, previous);​

 

I selected the Assignment Group and created an SC Task.The workflow is started from an After Insert
Business Rule.
The workflow starts successfully. I added a notification activity after the Assign activity, and the notification is sent to both users.

However, the task is not being assigned to the Primary On-Call user. Only the notification is working.

Can anyone suggest what needs to be checked to make the assignment work
0 REPLIES 0