How to exclude weekends from selected days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 09:49 AM
i have date/time field alredy some functionality is running
simply i am ordering one item i want to delivery the item within 10 days (today+10days) i am getting 05/03/2017..it is working fine..here i want to exclude the weekends
and my delivery date is not in weekend
can you please suggest how to proceed this task

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 09:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 10:09 AM
Hi Rakesh,
To apply to an existing field, you should leverage the GlideSchedule API.
See handy scripts on the wiki for examples or this link GlideSchedule API - http://wiki.servicenow.com/index.php?title=Scoped_GlideSchedule_API_Reference#gsc.tab=0
This will however only update your field, it wont take care of the shopping basket info and the Request/Request Item Delivery date provided by the system, however you can easily achieve this by applying a schedule (Weekdays only) to the items associated workflow. Schedules allow further conditions and factors such as business day duration and public holidays if required.
To update the workflow, navigate to the item and find the Workflow associated to the item. Then, via the the 'Workflow' editor, open the respective workflow and check it out. Open the properties and navigate to the 'Schedule' tab. Click on the Schedule field magnifying glass and select a schedule that best fits - a number are available out of the box ready for you. (You can also create your own Schedule(s) if desired)
See below screen shot
Rakesh, please can you mark correct and helpful by clicking on your post link (How to exclude weekends from selected days ) to help others with the same question as well as helping close out open questions.
Thanks,
Robbie
(Workflow Properties - Schedule field selection)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 10:09 AM
You need to use GlideSchedule API for this.
var startDate = new GlideDateTime('start date');
var days = 10;
var dur = new GlideDuration(60 * 60 * 24 * 1000 * days); // your duration goes here
var schedule = new GlideSchedule('sys_id of your weekday schedule');
var end = schedule.add(startDate, dur);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 10:39 PM
Hi Abhinay,
thanks for your replay..
i will explain little more clearly..for example i want to delivery the item 10 days (today+10 days) finally 06/02/2017 this is the present functionality..i want to modiy this functionality (exclude the weekends here 25/26 and 4/5 dates are weekend comes before 06/02/2017) i want to exclude this four days and in future weekends finally my delivery time is 10/03/2017
can you please suggest how to procedd with this task
thanks
Rakesh m