- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2011 03:28 AM
Hi all,
It appears that none of the metrics display the business duration.
To report of the amount of time a particular task was assigned to each support groups using the business hour i.e. incorporate the default schedule/calendar
Currently the 'Assignment Group' metric does perform this action, however, the duration calculated does not take into account the business hours.
There is a field on the metrics table called 'business hours' but it is always blank.
Any ideas?
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2011 02:38 PM
sncuser
The official response from support is that the issue reported above is a bug. They have logged a problem for it to be fixed in the subsequent releases.
The workaround for the specific issue above is to add a line of code in the Metrics Script Include as follows:
Navigate to Script Includes
Find the Record named "MetricInstance"
Find the function "endDuration", modify it to the following: (added line commented below)
endDuration: function() {
var gr = new GlideRecord('metric_instance');
gr.addQuery('definition', this.definition.sys_id);
gr.addQuery('id', this.current.sys_id);
gr.addQuery('calculation_complete', false);
gr.query();
if (!gr.next())
return;
gr.end = this.current.sys_updated_on;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.business_duration = gs.calDateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue()); // This is the added line!
gr.calculation_complete = true;
gr.update();
}
Also to note: You may or may not be aware that 'gs.calDateDiff' uses the first Calendar in the system. Calendars are legacy and have been replaced by Schedules. So to modify the above to use schedules look at the wiki article below:
http://wiki.service-now.com/index.php?title=Calculate_Duration_Given_a_Schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2013 08:15 AM
I appreciate this input! I'm running into the same issue....can you provide what your check looks like on your workaround script as I need to specify a schedule as well. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2013 12:32 PM
I tried modifying the following in my script includes....doesn't calculate at all now. Help Help!
var s = current.incident_state;
if (s >= 6)
createMetric();
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
var sched = new GlideSchedule('76dfb5256fca8900fe2a884f8e3ee451'); //Added this line
gr.start = current.sys_created_on;
gr.end = current.sys_updated_on;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.business_duration = (sched.duration(start.getGlideObject(), end.getGlideObject())); //Added this line
gr.calculation_complete = true;
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2014 02:50 AM
Not sure if this still actual, but i also faced the same issue with business time so let me recap all of the above
I used the scenario of Chris, thank you for idea
So i add "Schedule" field in definition (u_schedule) and used this field to check in script "MetricInstance"
in function "endDuration"
if (this.definition.u_schedule!=""){
if (typeof GlideSchedule != 'undefined'){
var sched = new GlideSchedule(this.definition.u_schedule);}
else{
var sched = new Packages.com.glide.schedules.Schedule(this.definition.u_schedule);}
var dur = sched.duration(gr.start.getGlideObject(), gr.end.getGlideObject());
gr.business_duration = dur;
}
It might be helpful