Multiple reminder notifications has been triggering through the schedule job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi Team,
I have a requirement to create a reminder notification on the Approval table.
Conditions:
- The approval state should be "Requested"
- The approval record should have been created at least 24 hours earlier
- The approver should receive the notification at 11 AM according to the user's timezone
To achieve this, I created a Scheduled Job that runs every hour and adjusts according to the user's timezone. However, users are receiving multiple reminder notifications, which should be avoided.
To prevent duplicate reminders, I added a custom field u_approval_reminder (Date/Time) to track when the last reminder was sent. I implemented the following logic to not send multiple reminders, but it’s not working as expected:
var sentRecently = false;
if (gr.u_approval_reminder) {
var lastSent = new GlideDateTime(gr.u_approval_reminder);
var diff = now.getNumericValue() - lastSent.getNumericValue();
// 24 hours in ms
if (diff < 86400000) {
sentRecently = true;
}
}
if (sentRecently) {
continue;
}
gr.u_approval_reminder = now;
gr.update();}