Adding condition to a scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 11:34 PM
Run scheduled job script on last day of each month for monthly frequency. if frequency is quarterly then it should run on last day of quarter. if frequency is yearly then it should run on last day of year. if frequency is half yearly then it should run on last day of half year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 01:46 AM - edited 03-21-2023 01:47 AM
Hi @Pratiksha Lang1 ,
You can configure the conditions based on the frequency of the job. Here's an example:
- If the frequency is "monthly," add a condition that checks whether the current day is the last day of the month. The condition would look like this: gs.isLastDayOfMonth().
- If the frequency is "quarterly," add a condition that checks whether the current day is the last day of the quarter. The condition would look like this: quartersAgoEnd(Number quarters) - Returns the date and time for the last day of the quarter for a specified number of quarters ago.
- If the frequency is "yearly," add a condition that checks whether the current day is the last day of the year. The condition would look like this: gs.isLastDayOfYear().
If my response helps you to resolve the issue close the question by ✅Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 01:58 AM
so are you having only 1 scheduled job? if yes then what's the configuration etc
share screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 02:11 AM - edited 03-21-2023 02:15 AM
@Ankur Bawiskar Yes there is only 1 scheduled job in which I have written the script which I want to execute on the basis of frequency field value. for example. for monthly frequency it should run on every month last day and for quarterly on last day of quarter.
In this condition I have to write it to run the scheduled job on monthly, quarterly etc