Scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 11:53 AM
How do i run a scheduled job quarterly on 1st,20th,30th of each till now i worked on this code this seems not be working :
(function() {
var today = new GlideDateTime();
var day = today.getDayOfMonth();
var month = today.getMonthUTC();
if ((day == 1 || day == 10 || day == 20) && (month == 0 || month == 3 || month == 6 || month == 9)) {
var templates = new StdChangeUtils().getNotUsedTemplates(gs.getProperty('change.std.months_before'));
if (templates.length > 0) {
gs.eventQueue('change_form_inactivity', null, templates.toString(), '');
}
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 12:24 PM
@rahul122 The code seems fine, please check if your scheduled job is scheduled to run daily.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 01:44 AM
yes @Sandeep Rajput it is scheduled to run daily

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 02:31 AM
Then ideally it should trigger notifications on every first, 20th and 30th day when month is Jan, March, June or September.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 12:26 PM
Hi @rahul122 ,
Your current script logic has a small error: it checks for day 10 instead of day 30. Here's a revised version of your script:
(function() {
var today = new GlideDateTime();
var day = today.getDayOfMonth();
var month = today.getMonthUTC();
if ((day == 1 || day == 20 || day == 30) && (month == 0 || month == 3 || month == 6 || month == 9)) {
var templates = new StdChangeUtils().getNotUsedTemplates(gs.getProperty('change.std.months_before'));
if (templates.length > 0) {
gs.eventQueue('change_form_inactivity', null, templates.toString(), '');
}
}
})();
Thanks.
Hope it helps.
Mark it helpful and accept solution if my response turns useful.