Need to send reminder emails on 3rd business day for specific catalog item approval records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 08:41 AM
Hello everyone, I'm currently facing an issue where an event is triggered for unapproved items on the 3rd business day. However, since the schedule job runs daily, the event continues to fire on subsequent days if the item remains unapproved. I need the email notification to be sent only on the 3rd business day, not afterward. The script I have is working, but it doesn't accurately count the 3rd business day. Any help would be appreciated.
function getBusinessDaysAgo(daysAgo) {
var date = new GlideDateTime();
var count = 0;
while (count < daysAgo) {
date.addDaysLocalTime(-1);
var dayOfWeek = parseInt(date.getDayOfWeekLocalTime(), 10); // 1 = Monday, 7 = Sunday
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
count++;
}
}
return date;
}
var threeBusinessDaysAgo = getBusinessDaysAgo(2);
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addEncodedQuery('state=requested^sysapproval.ref_sc_req_item.cat_item.category=8947562829022');
approvalGR.addQuery('sys_created_on', '<=' , threeBusinessDaysAgo); this condition only working
// '=' it not working and //approvalGR.addQuery('sys_created_on', threeBusinessDaysAgo) this condition also not working
approvalGR.query();
while (approvalGR.next()) {
gs.eventQueue('service.3daysremainder', approvalGR);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 08:51 AM
Hi @Navinr
you will might need to define not only 3 days ago, but also 2 days ago. To trigger when it is more than 2 days ago but not after 3 days ago.
Or to play with that condition, you can use background script to find it faster then triggering it
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */