- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2021 11:53 PM
Hi,
Can someone advise the script needed in Performance Analytics to calculate the duration between two fields. For example I would like to calculate the duration between when the incident was opened and when it was assigned to someone.
Thank you in advance.
Solved! Go to Solution.
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2021 09:53 AM
For time to assignment metrics, I prefer leveraging an SLA since this will allow me to easily calculate business time in addition to absolute time. Reporting on SLAs is then pretty straight-forward.
If you don't go down this path, you need a Performance Analytics script to perform this calculation per row. This cannot be done in a Formula since they operate on aggregates.
There should be examples available OOTB based on resolved time. Just be sure to handle unassigned tasks as well (with score_start) or exclude them from your indicator. This is the primary use case for Performance Analytics scripts and can also be found in the docs: https://docs.servicenow.com/csh?version=latest&topicname=pa-scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2021 07:51 AM
Adding logic into the reporting is challenging. The way I normally solve that is with business rules or a scripted metric. Alternatively, a job to process the data works too. We want to do the transformations ahead of time so the reports are simple.
Here is a longer explanation of they I take this approach: https://community.servicenow.com/community?id=community_blog&sys_id=2f99990fdbee5b00fece0b55ca9619fb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2021 12:09 AM
The link is not really what I mean, let me try and clear up. The script below calculates the time between when the ticket was opened and when it was assigned to a Incident Manager (which has a metric table entry). However there is a possibility the field might be updated to someone else, but we would only want to calculate the difference between when it was opened and when it was first assigned, not every time it is assigned. Is this possible without building SLAs via scripts?
// Used fields: current.inc_opened_at, current.mi_start
var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var minutes=function(x,y){return diff(x,y)/(60*1000);};
minutes(current.inc_opened_at, current.mi_start);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2021 01:55 AM
Thanks its helpful