ServiceNow – Use of ‘Scheduled Entity Generation’ for Scripted Job Scheduling.

Sometimes as an administrator you need to automatically run a Template to create a record against none OTTB schedules. In that case using ‘Scheduled Entity Generation’ can be used as allow scripting. In this example we are looking to run the template every 3rd Thursday of the month.

  1. Create your Template.
  2. Created your ‘Scheduled Entity Generation’ (sysauto_template.list).
  3. Link the ‘Scheduled Entity Generation’ to your template.

As creating templates tend to be common knowledge for administrators this article is skipping that part and jump straight to creation of ‘Scheduled Entity Generation’.

Scheduled Entity Generation:


function checkThirdTuesday(workDay){
var ordinals = ["", "1", "2", "3", "4", "5"];
var date = String(new Date());
var tokens = date.split(" ");
var floatNumber = ordinals[Math.ceil(tokens[2]/7)];
var weekDay = tokens[0]; if(floatNumber == "3" && weekDay == workDay)
result = true;
else
result = false; return result;
}
checkThirdTuesday(‘Tue’);

Note:

For scheduled job types that require an entered time, you have the option to enter an associated time zone. If no time zone is selected, the job will run at the entered time in time zone of the user who entered the time. If ‘Use System Time Zone’ is selected, the entered time will run in the time zone of the instance running the job.

Leave a Reply