Scheduled job execution on 23rd working day of every month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 11:14 PM
How to trigger a scheduled job on 23rd working day of all month

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 11:18 PM
Hi there,
Would this work for you?
Assuming you mean Day on the month, not workday. There are not many months with 23 workdays.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 11:44 PM
Hi ,@JPSS
Try below solution
To exclude holiday, use Schedule.
- Create a new Schedule (from Navigator, go to System Scheduler > Schedules > Schedules)
Add "Holidays *(exclude)" as a Child Schedule. for e.g. OOB schedule-"8-5 weekdays excluding holidays" - Create scheduled job with Run as daily and check Conditional checkbox.
- In condition box, add below script
function checkIfTwentythirdDay() { var gdt = new GlideDateTime(); var days = 22; var today = new GlideDateTime(); return (today.getDayOfMonthLocalTime() == twentyThirdDay.getDayOfMonthLocalTime()); checkIfTwentythirdDay(); |
Kindly mark my response helpful/accepted if it helps.
Regards,
Priyanka Salunke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 11:46 PM
Hi @JPSS
Please refer below snip. I am assuming that you want to trigger the scheduled job on 23rd of every month. If your requirement is to run this scheduled job on 23rd working day of the month, refer this post https://www.servicenow.com/community/developer-forum/schedule-job-to-run-on-every-11th-business-day-...
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 12:16 AM
To trigger a scheduled job on the 23rd working day of all month in ServiceNow, you would need to create a scheduled job and use a script to calculate the 23rd working day of the month. Here's a step-by-step guide:
1. Navigate to System Definition > Scheduled Jobs.
2. Click New to create a new scheduled job.
3. Fill in the necessary fields such as Name, Description, and Class.
4. In the Run field, select "Periodically".
5. In the Repeat Interval field, select "Monthly".
6. In the script field, you would need to write a script that calculates the 23rd working day of the month. This script would need to take into account weekends and public holidays. Here's a basic example of how you might do this:
javascript
var today = new GlideDateTime();
var month = today.getMonth();
var year = today.getYear();
var workingDays = 0;
var day = 1;
while (workingDays < 23) {
var date = new GlideDateTime();
date.setDate(year, month, day);
var dayOfWeek = date.getDayOfWeek();
// Skip weekends
if (dayOfWeek != 1 && dayOfWeek != 7) {
workingDays++;
}
day++;
}
// The 23rd working day of the month
var targetDate = new GlideDateTime();
targetDate.setDate(year, month, day - 1);
7. Click Submit to save the scheduled job.
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - nowgpt.ai