Duration field value not displaying properly in reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2016 08:21 AM
I have created a new field on the Incident table with a type Duration to calculate the age of open incidents (datediff from opened to today). The calculation works and the field displays correctly on the incident form, however I am not able to report off of this field correctly.
First - if I create a list report I see the values (eg. 2 days 11 hours and 29 minutes) but I can't sort this column. I can sort other duration columns, like Business Duration, that display the data in the same format.
Second - If I create a chart report it automatically tries to group the duration in Report Ranges but doesn't recognize the amount of time. So I get a bar chart with all the incidents in the 'empty' column and all the ranges (same day, 2-5 days, etc) have a count of 0.
I believe this is linked to a formatting issue but I've had no luck finding anything online.
Any help is much appreciated, and please let me know if you need additional details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2017 11:10 AM
The code (and method) I'm using is from here: Catalog Task (up-to-the-minute) Aging Report
gs.dateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2017 02:17 PM
I ended up working around this by not using a calculated value and instead creating a new business rule similar to the "mark_closed" business rule on the problem and incidents tables to populate the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2018 06:40 PM
Thanks for pointing me to the right direction. I got the duration field working in the sc_task table now. When you created your BR were you able to retroactively run the BR for the closed task prior to creating the BR.
I am only able to get the duration for current tasks that were closed after i created the BR and not before
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 09:40 AM
Hello All,
I am into a same fix here, I was able to create a metric which would calculate the duration based on various states I am able to see it in the metric list that the duration is working as expected...with various stages..but in the report I am unable to capture the value in which the task is currently in. Can someone help on this.
(function createMetric(definition,current){
var mi = new MetricInstance(definition,current);
var gr = mi.getNewRecord();
gr.start = current.sys_created_on;
gr.end = current.sys_updated_on;
gr.duration = gs.dateDiff(current.sys_created_on,current.sys_updated_on);
gr.calculation_complete = true;
gr.insert();
})(definition,current);