Script to trigger the notification daily to approvers

Shruti D
Tera Guru

Hello,

We have a requirement to trigger the email notification daily to the Multiple Group members having approvals in "Requested" state. This email should be triggered to each member separately with the link of the approvals to be actioned on.

It would be helpful if you suggest any solution

1 ACCEPTED SOLUTION

Shruti D
Tera Guru

1. A system property is created to store the sys_ids of the assignment groups.

2. An event is defined in the Event Registry, which will be triggered by a scheduled job.
3. A schedule item is created in the "sys_trigger" table to run daily.
The following script is used to send notifications to members of assignment groups who have approvals in the "Requested" state.

var abc = gs.getProperty('systempropertycreated');

var grApproval = new GlideRecord('sysapproval_approver');
grApproval.addEncodedQuery('state=requested^source_table=TableName^group.assignment_group.sys_idIN' + abc);
grApproval.query();
var userMap = {};
while (grApproval.next()) {

    var userSysID = grApproval.approver.toString();
    if (!userMap[userSysID]) {
        userMap[userSysID] = true;
        gs.eventQueue('EventName', grApproval, grApproval.approver.email, grApproval.approver.getDisplayValue());
    }
}


4. Created the notification containing links of records pending with approvals and associated it with the event created earlier by selecting the event name.

 

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Shruti D 

something like this as reminder flow which runs daily

check these videos, enhance it as per your requirement

https://www.youtube.com/watch?v=hVctTUMWIcs

https://www.youtube.com/watch?v=zsY0JyVBPz4

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Shruti D
Tera Guru

1. A system property is created to store the sys_ids of the assignment groups.

2. An event is defined in the Event Registry, which will be triggered by a scheduled job.
3. A schedule item is created in the "sys_trigger" table to run daily.
The following script is used to send notifications to members of assignment groups who have approvals in the "Requested" state.

var abc = gs.getProperty('systempropertycreated');

var grApproval = new GlideRecord('sysapproval_approver');
grApproval.addEncodedQuery('state=requested^source_table=TableName^group.assignment_group.sys_idIN' + abc);
grApproval.query();
var userMap = {};
while (grApproval.next()) {

    var userSysID = grApproval.approver.toString();
    if (!userMap[userSysID]) {
        userMap[userSysID] = true;
        gs.eventQueue('EventName', grApproval, grApproval.approver.email, grApproval.approver.getDisplayValue());
    }
}


4. Created the notification containing links of records pending with approvals and associated it with the event created earlier by selecting the event name.