- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 08:38 AM
Hi All,
How can we exclude Weekends from Business duration Calculation?
I'm getting 0 seconds as calculated Business Duration.
Can someone please help me to correct the below code.
Below is my code for reference.
function setClosureFields() {
current.active = false;
if (current.closed_by.nil())
current.closed_by = gs.getUserID();
if (current.closed_at.nil())
current.closed_at = gs.nowDateTime();
var dataChange = current.opened_at.changes() || (current.closed_at.changes() && !current.isValidField("u_resolved"));
var opened = current.opened_at.getDisplayValue();
var closed = current.closed_at.getDisplayValue();
var resolved = current.u_resolved.getDisplayValue();
var startDate = new GlideDateTime('opened');
var endDate = new GlideDateTime('closed');
var sched = new GlideSchedule();
sched.load('9fdacfe46f24ee00a3f0884f8e3ee4e6'); //sys_id of the schedule used i.e. Mon - Fri
var duration = sched.duration(startDate,endDate); current.business_duration = duration.getDurationValue();
if (dataChange || current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, resolved, false);
if (dataChange || current.u_resolved.nil())
current.u_resolved = current.closed_at;
}
Thanks and Regards,
Meenal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 08:52 AM
Chk if this helps
Mark my ANSWER as CORRECT and HELPFUL if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2019 08:52 AM
Chk if this helps
Mark my ANSWER as CORRECT and HELPFUL if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 02:51 AM
Hi,
Tried using the above link.
I got an error because of newGlideObject()
Thanks and regards,
Meenal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 03:02 PM
Cannot access this URL.
Could you help on calculating the working days ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 03:34 AM
Hi ,
Thanks for your Help.
It worked.
Thanks and regards,
Meenal