Trigger same event while scheduled job runs in 2 different condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 12:32 AM - edited 04-26-2025 01:13 AM
Hi All,
I have a schedule job which triggers an event . Now the recipients receives a reminder only when the capacity review due date was 14 days away. Want to send an additional reminder 7 days before the due date. What changes should i make on the below script in schedule job so that I can achieve it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 12:38 AM
try this
var gr_user = new GlideRecord('u_capacity_reviews');
gr_user.addEncodedQuery('u_status=pending^active=true');
gr_user.query();
while (gr_user.next()) {
var reviewdate = new GlideDateTime(gr_user.u_capacity_review_due_date.toString());
// Calculate 14 days before the due date
var reminder14Days = new GlideDateTime(reviewdate);
reminder14Days.addDaysLocalTime(-14);
// Calculate 7 days before the due date
var reminder7Days = new GlideDateTime(reviewdate);
reminder7Days.addDaysLocalTime(-7);
var currentDate = new GlideDate().getDisplayValue();
// Check if today is 14 days or 7 days before the due date
if (currentDate == reminder14Days.getDisplayValue() || currentDate == reminder7Days.getDisplayValue()) {
gs.eventQueue('notify.capacity.reviewers', gr_user, gr_user.u_application_instance.u_support_owner, gr_user.u_application_instance.owned_by);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 02:50 AM
Unable trigger mail after this schedule script . I have checked email logs , not getting the emails that i observed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 03:12 AM
what debugging did you perform?
did you add logs and see?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 09:24 AM - edited 04-26-2025 04:09 AM
I have tried the below script and actually I don't want to change anything on the highlighted part. Just want to add the the script for 7 days . Please correct me if my script is wrong. I have tried this and then observed the schedule log that it's last run is 22nd where the schedule job runs daily . For today there are no logs. I am adding the pics of schedule job and schedule log for your reference.