Help with On-call workflow

markchristianh
Tera Contributor

Hi,

 

Please help me on how I implement the requirement below:

I'm not very familiar with using the legacy workflow editor and been working with this task but I'm unable to completely do it.

 

current workflow: on-call assign by acknowledgement per rota

Current happening:

If an incident was created, the orkflow will check if there's an on-call and send's notification, if user didn't acknowledge it will not assign the incident and move to the next user.

 

Requirement:

When a incident was log the workflow will check if there's a current on-call, if there is it will assign the incident right away and send notification for user to acknowledge, if the user didn't acknowledge it will re-assign the incident to the next on call and send another notification.

2 REPLIES 2

Naveen20
ServiceNow Employee
Try these
Step 1: Copy the OOTB Workflow

Navigate to the workflow editor and open "On-Call: Assign by Acknowledgement per Rota". Right-click and create a copy so you have the original as a fallback.

---

Step 2: Add a "Set Values" / "Run Script" Activity to Assign Immediately

After the "More Escalation Levels Available?" activity (which resolves the current on-call escalatee), add a new Run Script activity BEFORE the notification activity. This assigns the incident right away:

```javascript
var rota = new SNC.OnCallRotation();
var gdt = new GlideDateTime();
var level = workflow.scratchpad.currentLevel + "";
var currentEscalatee = rota.getEscalateeAt(
workflow.scratchpad.assignment_group, gdt, level
);

if (currentEscalatee && currentEscalatee.sys_id) {
current.assigned_to = currentEscalatee.sys_id;
current.update();
}
```

This is the key change — in the OOTB workflow, assignment only happens after acknowledgement. Here we are flipping it to assign first.

---

Step 3: Keep the Notification and Timer Activities

Leave the existing notification (SMS/email/voice) and Timer activities in place after your new assignment activity. The user still receives the notification and is expected to acknowledge.

---

Step 4: Modify the Timeout (No Acknowledge) Path

On the timeout/rejection path, add a Run Script activity that reassigns to the next on-call escalatee:

```javascript
var rota = new SNC.OnCallRotation();
var gdt = new GlideDateTime();
var escalationPlan = rota.getEscalationPlan(
workflow.scratchpad.assignment_group, gdt
);

var nextLevel = workflow.scratchpad.currentLevel + 1;
if (escalationPlan.size() >= nextLevel) {
var nextEscalatee = rota.getEscalateeAt(
workflow.scratchpad.assignment_group, gdt, nextLevel + ""
);
if (nextEscalatee && nextEscalatee.sys_id) {
current.assigned_to = nextEscalatee.sys_id;
current.update();
workflow.scratchpad.currentLevel = nextLevel;
}
} else {
// Escalation exhausted — optionally notify group manager
gs.log("Escalation plan exhausted for: " + current.number);
}
```

Then connect this activity's transition back to the "More Escalation Levels Available?" check to create the escalation loop.

---

Step 5: Update the Trigger Rule

Navigate to On-Call Scheduling → Administration → Trigger Rules and update your trigger rule to point to your new copied workflow instead of the OOTB one.

Important: If your assignment_group is already populated before the trigger rule fires (e.g., via category-based assignment rules), the trigger rule won't fire — this is a known platform behavior. In that case, launch the workflow from a Business Rule instead:

```javascript
// Business Rule: After Insert on Incident
// Condition: assignment_group is not empty
function onAfter(current, previous) {
var wf = new Workflow();
wf.cancel(current);
wf.startFlow('<your_copied_workflow_sys_id>', current, current.operation());
}
```

If you go the Business Rule route, also update the "Is there any schedule at the time?" activity inside the workflow — change `vars.assignment_group` to `current.assignment_group` since the vars object won't be passed in from a BR.

Summary of the modified flow:

Begin → Is there a schedule? → More Escalation Levels? → Assign to on-call user → Send Notification → Timer (wait for ack) → Acknowledged? → Yes → End / No → Reassign to next escalatee → Loop back to "More Escalation Levels?"

Trying this now will let you know if it works thank you!