Scheduled Job in ServiceNow for approval reminder notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I have created a Scheduled Job in ServiceNow for approval reminder notifications. The requirement is that the job should run only on Riyadh business working days (Sunday to Thursday) and should not execute on Friday and Saturday.
However, currently the Scheduled Job is running daily including weekends.
Current requirement:
- Run only Sunday to Thursday
- Timezone should follow Riyadh timezone
- Skip Friday and Saturday completely
I tried using schedule conditions, but the job is still executing daily.
Could anyone please suggest the best approach to Solve it.
Current script logic example:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Try with this condition. Update your code logic in Run script field. ,execute and check.
answer = checkCondition();
function checkCondition(){
var dayOfWeek = new GlideDateTime().getDate().getDayOfWeek();
// Monday is 1 and there onwards
if(dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 7)
return true;
else
return false;
}
Note: If you check It is not checking Riyadh Timezone, try with
answer = checkCondition();
function checkCondition(){
var dayOfWeek = new GlideDateTime().getDayOfWeekLocalTime();
// Monday is 1 and there onwards
if(dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 7)
return true;
else
return false;
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti