Run a duration field when incident is created and comlete when closed
This content was last updated in 2024. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2024 02:20 AM
we want to create a duration field which runs from 6am to 6pm monday to friday once incident is created and completes when incident is resolved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2024 02:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2024 02:31 AM
Not sla but a field called age to calculate incident duration and this should run only from 6am to 6pm monday to friday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2024 04:21 AM - edited ‎08-30-2024 04:22 AM
Hi @sunil kumar6 ,
One way is to get the complete duration when an incident is Completed (resolved / Closed) using a Schedule in a business rule.
First create a schedule from 6am to 6pm Monday and Friday, and call the schedule in the business rule.
var startDate = new GlideDateTime(current.sys_created_on);
var endDate = new GlideDateTime(); // current time when business rule is triggered (condition state is closed/resolved)
var schedule = new GlideSchedule();
schedule.load(' '); // loads "6am-6pm weekdays excluding holidays" schedule (sys_id of the schedule)
var duration = schedule.duration(startDate, endDate);
gs.info(duration.getDurationValue()); // gets the elapsed time in schedule
Update the custom field with duration.getDurationValue();
Hope this helps.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 02:00 AM
Hello Najmuddin,
i have tried this script its not calculating the duration.