How to Trigger Push Notification to Former Assignee When WOT Visit Unassigned
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2025 02:08 AM
Hi Community,
I'm working on a push notification in our FSM project and need some guidance.
Scenario:
- A WOT bundle or standalone WOT is assigned to agent,
- The Scheduled Start Time is within the next 2 hours,
- If the agent is unassigned from the visit (due to removal, rescheduling, or cancellation),
- A push notification should be sent to the former assignee with the message: "WOTID removed. Review your upcoming visits."
- Clicking the notification should direct the agent to the "My Tasks" screen.
What I've done so far:
- Created the Push Notification Message and Push Notification Content,
- Created the Notification,
- Registered the Custom Event.
My questions:
- Do I need to create a Business Rule or a Script Include to trigger the custom event when the agent is unassigned?
- How can I capture the former assignee to send the notification after the unassignment? Since after unassigning, the Assigned To field becomes empty, how can I reference the person who was assigned before the change?
- What's the best approach to send the notification to this former assignee after the task is unassigned?
Appreciate any suggestions, examples, or best practices. Thanks in advance!
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2025 02:27 AM
Hi @Nataliia_Lova
With Business Rule we can compare current.assigned_to (new value) with previous.assigned_to (old value) and If current.assigned_to is empty and previous.assigned_to has a value, the agent was unassigned.
Condition: (assigned_to.changes() && !current.assigned_to.nil()) || (assigned_to.changes() && current.assigned_to.nil())
(function executeRule(current, previous) {
if (current.assigned_to.nil() && !previous.assigned_to.nil()) {
var scheduledStart = new GlideDateTime(current.scheduled_start);
var now = new GlideDateTime();
var twoHours = gs.minutesAgo(-120); // 2 hrs ago
if (scheduledStart.after(twoHours) && scheduledStart.before(now.addHours(2))) {
var formerAssignee = previous.assigned_to;
// Trigger your event
var event = new GlideRecord('sysevent');
event.initialize();
event.setValue('name', 'wot.unassigned.notification');
event.setValue('parms', {
assignee: formerAssignee,
wot_id: current.sys_id,
message: 'WOT' + current.number + ' removed. Review your upcoming visits.'
});
event.insert();
}
}
})(current, previous);
Thanks,
Tushar