How can I set up a PA indicator to measure a SC Task open to closed duration, minus weekends?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2022 08:35 AM
Hi Service Now community,
I am looking to set up a PA dashboard and indicator to measure the time to resolve all service requests. By getting an overall average, we can then see which requests are taking too long and which are potential for automation. Additionally, we may want to adjust the SLA if appropriate.
However, when calculating the duration, we need to remove the weekends and possibly count working hours only ie. 8-6pm. Does anyone know how this can be configured?
Thanks.
Chas.
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2022 02:27 PM
Hi Chas,
This calculation can be done via a Metric Definition on the sc_task table:
var s = current.active;
if (s == false)
createMetric();
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
var gsBusiness =new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); // sysid of the Business Schedule
gr.start = current.sys_created_on;
gr.end = current.sys_updated_on;
// Get duration based on the Business Schedule
gr.business_duration = gsBusiness.duration(gr.start.getGlideObject(), gr.end.getGlideObject());
gr.calculation_complete = true;
gr.insert();
}
Regards.
JP
JP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2022 02:34 PM
Hi Chas,
Once the metric definition is in place, you may then report on the sc_task_metric database view or use that view to set up your daily PA Indicator.
Regards.
JP
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2022 02:22 AM
This is great JP. I'll give this a try.
Do you know whether it is possible to script this into a PA Automated indicator? It would mean that I can avoid creating a metric and just measure in PA.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 05:24 AM
Hi Chas,
You will need both.
You need the metric to get your raw data and you will have to define your PA Indicator Source using the sc_task_metric database view.
Once the PA indicator source is defined, you may create your PA Indicator and set the data collection.
Regards.
JP
JP