- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:20 AM - edited 07-18-2024 11:25 AM
I am looking to make an adjustment to a Scheduled jobs which run monthly and quarterly basis.
The monthly runs monthly,
But it is not required on the quarterly schedules run on, which is in the months of January, April, July and October.
Is there a conditional clause that that would tell the monthly jobs not to run on months when the quarterly jobs run?
What I am thinking is to make a condition in the script to tell it to not run the monthly one on certain months you specify, this is where my head is at.
Their is a condition checkbox on the form how to script this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:48 AM - edited 07-18-2024 12:09 PM
Hi @Joshua Comeau ,
You need to check the condition box and write a script to identify the month. If those conditions will be satisfied then job will run else it won't run.
function checkMonth()
{
var gd = new GlideDateTime();
var getMonth = gd.getMonth();
//Here, 1 is January and 12 represent December
//Update months as per your requirement
if(getMonth == 1 || getMonth == 12) {
return true;
}
else{
return false;
}}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:50 AM
//Return 'true' to run the job
var answer = false;
//Get the month of the year. 1=January, 12=December
var now = new GlideDateTime();
//Run quarterly
month = now.getMonth();
if(month == 1 || month == 4 || month == 7 || month == 10){
answer = true;
}
answer;
was looking for an example towards the script from this would this work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 12:12 PM - edited 07-18-2024 12:12 PM
Thanks @Joshua Comeau for marking helpful. Could you please also accept it as solution, as multiple answers could be marked as solution if the solution helped.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:48 AM - edited 07-18-2024 12:09 PM
Hi @Joshua Comeau ,
You need to check the condition box and write a script to identify the month. If those conditions will be satisfied then job will run else it won't run.
function checkMonth()
{
var gd = new GlideDateTime();
var getMonth = gd.getMonth();
//Here, 1 is January and 12 represent December
//Update months as per your requirement
if(getMonth == 1 || getMonth == 12) {
return true;
}
else{
return false;
}}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:50 AM
//Return 'true' to run the job
var answer = false;
//Get the month of the year. 1=January, 12=December
var now = new GlideDateTime();
//Run quarterly
month = now.getMonth();
if(month == 1 || month == 4 || month == 7 || month == 10){
answer = true;
}
answer;
was looking for an example towards the script from this would this work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 11:56 AM - edited 07-18-2024 11:58 AM
@Joshua Comeau yes, looks good. You can try it. Instead of answer, try with return true or false.
I have attached a script in the above response.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 12:12 PM - edited 07-18-2024 12:12 PM
Thanks @Joshua Comeau for marking helpful. Could you please also accept it as solution, as multiple answers could be marked as solution if the solution helped.
Mark this as Helpful / Accept the Solution if this helps.