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

How to Assign Ticket to Primary On-Call User and Notify Both Primary & Secondary Users?

NishmithaS
Tera Contributor

Hi All

I am  using the On-Call: Assign workflow, which only assigns the ticket to the Primary On-Call user.

We also have the On-Call: Escalation by Email workflow, which sends notifications to the Primary and Secondary On-Call users, but it does not assign the ticket.

Requirement: The ticket should be assigned to the Primary On-Call user, and email notifications should be sent to both the Primary and Secondary On-Call users.

Can anyone please help me understand the best way to update the workflow to achieve this requirement?
1 ACCEPTED SOLUTION

Shahjay
Kilo Guru

I wouldn’t chain those two workflows. They’re doing different jobs. On-Call: Assign figures out the current primary and sets assigned_to. Escalation by Email walks the escalation plan over time, which is why the secondary only gets mailed after the primary’s reminders time out. That’s escalation, not “tell both of them now.”

What’s worked well for this is leave assignment alone and add your own notification to primary and secondary together:

  1. Copy On-Call: Assign (leave the OOB one alone).
  2. After the activity that assigns the primary, add a Run Script that pulls the first two escalatees from the rota and fires an event.
  3. Register the event under System Policy > Events > Registry on your task table, e.g. oncall.primary_secondary.notify.
  4. Create a notification on that event and tick “Event parm 1 contains recipient.”
  5. Point the trigger rule at the copied workflow.
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; // primary (1) and secondary (2) only
    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(','), '');


Ticket still goes only to the primary; both get the email at the same time. Because the users come from the rota when the workflow runs, overrides and shift changes are picked up automatically.

Check the order values against your own escalation setup. If the rota escalates by roster rather than by member, userIds can include everyone on that roster, which may be more people than you want to email.

One more trap: if assignment_group is mandatory and already filled when the record is created, the trigger rule sometimes never attaches the workflow (KB0784518). In that case start the copied workflow from an after insert/update business rule when the assignment group changes.


If this response helped, please mark it as correct and close the thread ✅ — it helps future readers find the solution faster.

Thanks

View solution in original post

5 REPLIES 5

Hi @Shahjay 

Thank you so much