
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 06:42 AM
Hi all,
I'm trying to generate the duration of a SC Task or RITM. I found the following KB article:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0684036
I've updated the Close Ticket business rule as it suggests but the the Business Duration field is not populating...
Any help greatly appreciated. I would like to do the same for RITMs too.
Many thanks
Tracey
Solved! Go to Solution.
- Labels:
-
Request Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 07:01 AM
Hi Tracey,
Could you try this script instead?
current.active = false;
current.work_end = nowDateTime();
current.business_duration = gs.dateDiff(current.opened_at.getDisplayValue(),current.work_end.getDisplayValue(),false);
Let me know the outcome.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 07:01 AM
Hi Tracey,
Could you try this script instead?
current.active = false;
current.work_end = nowDateTime();
current.business_duration = gs.dateDiff(current.opened_at.getDisplayValue(),current.work_end.getDisplayValue(),false);
Let me know the outcome.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 08:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 08:36 AM
Np Tracey.
I think it would be quite similar, but this time create a new business rule like this:
Script:
current.active = false;
if (current.closed_by.nil())
current.closed_by = gs.getUserID();
if (current.closed_at.nil()) {
current.closed_at = gs.nowDateTime();
current.business_duration = gs.dateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),false);
current.calendar_stc = gs.dateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),true);
}
Hope that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 09:32 AM