Consolidate multiple email notification in a single email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 10:13 AM
Hi,
We have a custom application. When a task/record is overdue then it will trigger a notification to user. Let's say if the user has 20 task/record overdue then it will send 20 notification to a user in a day.
Requirement is let's say user has 20 task/record overdue now notification of all those 20 tasks should be consolidated and send it in a single email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 11:50 AM
Hello @imran sk ,
you can generate just one one notification instead of many by :-
1 First create/register one event .
2 create a scheduled job by using the below code that will check the overdue task and generate the event for you
3 create one notification that will trigger based on event .
****scheduled Job**** frequency can be one time a day
/ Get today's time and date
var rightNow = new GlideDateTime();
// Query the database for Task records with Due date field values older
// than the current time. Only return Task records that do not have
// a State field value of Closed Complete.
var overdueTasks = new GlideRecord('<you task table name>');
overdueTasks.addQuery('due_date','<=',rightNow);
overdueTasks.addQuery('state','!=',3);// state is not equal to closed
overdueTasks.query();
// Write a log message for each overdue Task Record
while(overdueTasks.next()){
gs.info("Overdue NeedIt Task record = " + overdueTasks.number);
gs.eventQueue('<event name>',overdueTasks,overdueTasks.number,gs.getUserName());
}