- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 06:24 AM
I have a requirement to create a calculated field that shows how long it took for a RITM to be closed
RITM Closed - RITM Open = Duration.
How can this be achieved. any help on this is greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 06:51 AM
You can create a function field in your report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 07:54 AM
Is this required for reporting purpose or you want it as a field on RITM table?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 07:58 AM
@Ankur Bawiskar , this is basically for reporting purpose. I was advised by my team to create a SLA definition or a metric instead of creating a field on the sc_req_item table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 08:02 AM
that's correct. you can use metrics for this just like incident table
OR
you can use function field on the report created on RITM table.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 08:14 AM
To create a calculated field that shows how long it took for a RITM (Requested Item) to be closed using a script and calculate it for existing RITM records, you can follow these steps:
- Create new Field
- Give the new field a name, such as "Time to Close", and select the data type as "Duration".
- In the "Calculated Script" field, enter the following script(Click on the advanced tab):
- (function() {
var duration = 0;
if (current.closed_at && current.opened_at) {
var start = new GlideDateTime(current.opened_at.getDisplayValue());
var end = new GlideDateTime(current.closed_at.getDisplayValue());
var difference = gs.dateDiff(start, end, true);
duration = difference / (60 * 60 * 1000);
}
return duration;
})(); - This script calculates the time it took to close the RITM in hours by subtracting the "closed_at" date/time from the "Requested" date/time and dividing the result by the number of milliseconds in an hour.