Currently, Service-now.com doesn’t have a way to easily schedule data imports for weekdays only. You can do Daily, Weekly (on a day of the week), Monthly, Periodically, etc. However, if you want to do every week day, you are kind of out of luck.

You could Create five Weekly Imports all for a different weekday, but that gets a little cumbersome — especially if you have more than one scheduled data import.

I worked up another way this morning that might be useful. This method will use a Post-Script on a Daily Scheduled Data Import. After it runs the first time it will determine what day of the week it is. If it is a Friday, then it will set the “run_start” field to the following Monday’s date with the same time. This will cause the daily import to wait until Monday to run again. I have a sample script that does this below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
gr = new GlideRecord("scheduled_import_set");
gr.addQuery("name", [NAME OF YOUR SCHEDULED IMPORT]);
gr.query();
gr.next();

var run_start = new Packages.com.glide.glideobject.GlideDateTime(gr.run_start);

//Get Seconds of the original time so that
//we can preserve the original time in our new date
var seconds = run_start.getTime().getNumericValue()/1000;

var today = new Date();
var thisDay = today.getDay(); // returns 0 for Sunday, 1 for Monday, etc.
var thisMon = new Packages.com.glide.glideobject.GlideDateTime();
thisMon.setDisplayValue(gs.beginningOfNextWeek());

if (thisDay > 4) {
  //We are past Thursday...if this is running on a Friday
  //we want the next run to be on the following Monday
  run_start.setNumericValue(thisMon.getNumericValue());
}

//Subtract the current time from itself so that we start at 0:00:00 for time
run_start.subtract(run_start.getTime());

//We want to add the seconds for the time that
//the job was origianlly scheduled for so that
//we preserve the start time.
run_start.addSeconds(seconds);

gr.run_start = run_start;
gr.update();