- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 09:33 PM
I want my scheduled job to run only on business days.Can I use the schedule 8-5 weekdays excluding holiday in Scheduled job?
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 10:33 PM
Here's code you can add to the Scheduled Job to verify if it should run or not:
var schedule = new GlideSchedule("090eecae0a0a0b260077e1dfa71da828"); //replace sys_id with the id of the appropriate schedule
if(schedule.isInSchedule(new GlideDateTime(gs.nowDateTime()))){
//add your code here
...
}
It is an updated version of Mark Stanger (Crossfuze)'s response here - The easiest way to do this
This line of code (not tested) should work directly in the Condition field of your Scheduled Job:
new GlideSchedule("090eecae0a0a0b260077e1dfa71da828").isInSchedule(new GlideDateTime(gs.nowDateTime()))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 10:33 PM
Here's code you can add to the Scheduled Job to verify if it should run or not:
var schedule = new GlideSchedule("090eecae0a0a0b260077e1dfa71da828"); //replace sys_id with the id of the appropriate schedule
if(schedule.isInSchedule(new GlideDateTime(gs.nowDateTime()))){
//add your code here
...
}
It is an updated version of Mark Stanger (Crossfuze)'s response here - The easiest way to do this
This line of code (not tested) should work directly in the Condition field of your Scheduled Job:
new GlideSchedule("090eecae0a0a0b260077e1dfa71da828").isInSchedule(new GlideDateTime(gs.nowDateTime()))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 11:22 PM
Thank you Jim.
But I have one more question here.
My requirement is to generate a notification under 2 conditions for the change validation task.
a. Once the Validation Task "Requested End Date and Time" plus 4 calendar hours is reached.
b. This email notification will be re-sent to the Validation Task "Assigned to:" at 8, 16, and 24 business hours past the Task "Requested End Date and Time".
how can i achieve this.I have lots of confusion regarding this calculation.
if(parseInt(reqEndYear) == parseInt(curYear))
{
if(parseInt(reqEndMonth) == parseInt(curMonth))
{
gs.log("**Task on the same day " + valtask.number + "Current date " + curDate + "End Date " + reqEndOnlyDate);
if(parseInt(reqEndOnlyDate) == parseInt(curDate))
{
if(parseInt(reqEndHrs) + 1 == parseInt(curHour) || parseInt(reqEndHrs)+8 == parseInt(curHour) || parseInt(reqEndHrs)+16 == parseInt(curHour)){
gs.eventQueue("change_task.escalation.fired",valGr,taskAssignedTo,reqEndDate);
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2014 02:14 PM
I edited my post to add "gs.nowDateTime()" to the code in order to get the date/time back in the appropriate timezone. Without it, the date/time returned is based on GMT timezone, which could throw things off.