Need to Reduce email notifications for Timesheet Approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
We have a scheduled job which triggers the notification based for the time sheet submitted. This notification is triggered via event configured in the Scheduled Job. But the notifications are triggered multiple times to the user manager for the timesheets submitted, How we can change the script to triggered only one notification per manager so, that we can reduce the email notifications for the timesheet.
Scheduled script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
how is your notification configured? any email script?
check below links on how to combine and send 1 email, where I shared approach. enhance your code as per that
Email Notification to all users of assets assigned specifically to them
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago - last edited 7 hours ago
Hi @Tamilvanan T ,
Modify your Scheduled Job script to group timesheet records by the manager's ID before triggering the event and check once.
Sample Code:
var gr = new GlideRecord('ts_timesheet');
gr.addEncodedQuery('state=submitted'); // replace it by your condition
gr.query();
var mgrMap = {};
while (gr.next()) { var mgrSysId = gr.user.manager.toString(); if (!mgrMap[mgrSysId]) { mgrMap[mgrSysId] = []; } mgrMap[mgrSysId].push(gr.user.getDisplayValue() + " - " + gr.number); }for (var mngr in mgrMap) { var timesheetList = mgrMap[mngr].join(', '); gs.eventQueue('timesheet.approval.reminder', null, timesheetList, mngr); }