Comments on: Weekdays-only Scheduled Job https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 16:37:44 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mouli https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8239 Mon, 14 Sep 2015 12:30:40 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8239 Is it possible pause the schedule between a particular period in hours?

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8238 Thu, 14 Feb 2013 21:41:46 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8238 In reply to Jim Coyne.

Heads up! ‘Packages’ calls are going to be phased out starting with the Calgary release. There’s a migration utility that ServiceNow is going to provide, but you can replace ‘Packages.com.glide.schedules’ with ‘GlideSchedule’ starting in Calgary to make it work without a Packages call.

]]>
By: Jim Coyne https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8237 Tue, 31 Jan 2012 16:27:17 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8237 Good point. So this works:

var gr = new GlideRecord('cmn_schedule');
if (gr.get('name', 'Weekdays 08:00 - 17:00')) {
var schedule = new Packages.com.glide.schedules.Schedule(gr.sys_id);
if(schedule.isInSchedule(new GlideDateTime())) {
u_sendApprovalReminders();
}
} else {
gs.log('*** Approval Reminder - Schedule not found');
}

BUT only if you have everything defined on the same schedule. I was trying to create a master schedule (Weekdays 8:00 – 17:00) and then have a child schedule with the actual company holidays defined on it to exclude those days. Guess I’ll have to stick to just one schedule. :-)

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8236 Tue, 31 Jan 2012 02:43:36 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8236 In reply to Jim Coyne.

I hear you. ServiceNow dev keeps preaching that but until they give us something else to use we need to use packages calls. This one is fairly common though so they should make sure that whatever they change with it doesn’t cause any disruptions.

]]>
By: Jim Coyne https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8235 Tue, 31 Jan 2012 02:39:11 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8235 In reply to Mark Stanger.

I was hoping not to use a Packages function – I thought we were not really suppose to use them?

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8234 Mon, 30 Jan 2012 23:49:18 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8234 In reply to Jim Coyne.

Hey Jim,

I think you should be able to do this using ‘isInSchedule’ as shown here.
http://community.service-now.com/forum/7180

]]>
By: Jim Coyne https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8233 Sun, 29 Jan 2012 16:55:08 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8233 Now is it possible to find out if the current day is an actual work day based on a schedule? For example, I have the following Scheduled Script Execution that runs everyday at 8:00 AM to send out approval reminders:
var now = new Date();
var day = now.getDay();

// do not run on Saturday or Sunday
if (day != 0 && day != 6) {
u_sendApprovalReminder(); //Script Include
}

The Script Include actually does the sending of the emails. What I would like to do is skip the reminders on a weekday that may also be a company holiday. Is there a scripting method to tell whether a date is an active work day based on a defined schedule?

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8232 Fri, 21 Oct 2011 04:13:15 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8232 In reply to Alex Rivera.

Sounds like a copy/paste issue with the syntax highlighter on your script field. Make sure that you toggle the syntax highlighter off (using the middle icon at the top of the script field) before pasting. Let me know whether that works or not.

]]>
By: Alex Rivera https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8231 Thu, 20 Oct 2011 18:21:15 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8231 Hey Mark – I tried the script and it is throwing the following error:

JavaScript parse error at line (5) column (25) problem = missing ; before statement
Error:
Problem at line 8 character 27: Missing ‘;’

If(now.getDayOfWeek() < 6){ Problem at line 9 character 6: Expected to see a statement and instead saw a block. answer = true; Any recommendations?

]]>
By: Michele King https://servicenowguru.com/system-definition/weekdaysonly-scheduled-job/#comment-8230 Wed, 29 Jun 2011 07:38:56 +0000 https://servicenowguru.wpengine.com/?p=3377#comment-8230 Yeah, found the forum thread after I posted here but had already done exactly what the forum recommends and still was getting the null value back. I’ll try the script include instead. Thanks-Michele

]]>