How to use Schedules in a Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2017 10:43 PM
Hi Experts,
I am working on a catalogue item that auto-creates a Change Request upon approval of a Request Item. The Start Date is 5 business days after the create date of the Change Request and should not land on a weekday or holiday. I will be using the '8-5 weekdays excluding holidays' Schedule. I need your expert opinion how I can do this in the workflow.
Thank you!
Carlo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2017 10:54 PM
You can calculate start date adding schedule in your time calculation. Check below for your reference.
Calculating Due Date Based on Requested Date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 06:17 PM
Hi Deepak,
How can I do this if I want the Start Date to be 5 business days from now excluding weekends and holidays and at 1PM?
For example, the Change Request is created today (Sep 12). The Start Date should be Sept 17 9:00 AM.
Carlo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2017 10:57 PM
Hi
Yes you should be able to use the Timer activity to do this.
You need to convert the 5 business days into a number of hours eg. 40 hours and then select the schedule. The timer should take care of the rest.
If you want to generate the change right away but simply calculate the start date of the change to be 5 business days away you have to use the GlideSchedule api
https://developer.servicenow.com/app.do#!/api_doc?v=istanbul&id=c_GlideScheduleScopedAPI to add 5 days to the current time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 08:06 PM
Hi Experts,
This is the script to populate the Start Date in the workflow:
var nowGdt = new GlideDateTime();
var days = 5;
var dur = new GlideDuration(60 * 60 * 24 * 1000 * days);
var schedule = new GlideSchedule();
var end = schedule.add(nowGdt, dur);
gs.info(end);
current.variables.start_date = end;
The output is the correct date (5 days from now). However, I have no idea how to (a) remove the hours section and replace it with "09:00:00" and use the Schedule called '8-5 weekdays excluding holidays'.
Please help!
Thank you.
Carlo