Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Send Push Notification To Supervisor

yana7
Tera Contributor

I have a use case, which is to send a push notification to the supervisor when a work order is created.

Here are my business rules:

yana7_0-1717060732583.png

(function executeRule(current, previous /*null when async*/ ) {

    var mtcSupervisorSkillId = 'f6d604291b14c5506846db9fe54bcb18';
    // Get coverage groups for this task that have the maintenance supervisor skill
    var recipientGroups = global.getFsmCoverageGroupsWithSkills(current, [mtcSupervisorSkillId]);
   
    // Log an error if there's no group coverage for the WO task's location
    if (!recipientGroups) global.NiceError.raise(
        'Tried to send coverage-based notification for ' +
        current.number +
        ', but there there were no groups with coverage for the task location'
    );

    // Trigger the notification event
    recipientGroups.forEach(function(recipientGroup) {
        gs.eventQueue('fsm.work_order.created', current, recipientGroup);
    });

})(current, previous);

 

These are the events that trigger the notification:

yana7_2-1717060847031.png

 

These are the notification settings:

yana7_1-1717060801047.png

Tab who Will Receive

yana7_3-1717060880827.png

Tab Contain

yana7_4-1717060949603.png

 

 

Goal is this and Mobile

yana7_5-1717061133637.png

 

0 REPLIES 0