- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
We have an SLA based on the ‘First Response Duration’ field. When a user from a specific group comments for the first time, that duration is captured in the SLA field. We need to exclude weekends from this duration. We have already developed a Business Rule to populate the duration (see script below). Could you please suggest how to exclude weekends?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
First make sure the schedule record you are using has the correct timeframe and is excluding the weekends. Next use the "schedule.duration()" method. It looks like you tried "schedule.subtract" instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
Hey @TtharunS You can create a Schedule (cmn_schedule) record that excludes the weekend. Then use the GlideSchedule api to calculate the duration between the two dates. The duration method will do the calculation for you.
This is the code snippet from the documentation:
var startDate = new GlideDateTime('2014-10-16 02:00:00');
var endDate = new GlideDateTime('2014-10-18 04:00:00');
var schedule = new GlideSchedule();
schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule
var duration = schedule.duration(startDate, endDate);
gs.info(duration.getDurationValue()); // gets the elapsed time in schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
First make sure the schedule record you are using has the correct timeframe and is excluding the weekends. Next use the "schedule.duration()" method. It looks like you tried "schedule.subtract" instead.