- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2022 09:40 AM
Hi All,
The requirement is to calculate the duration between Incident Creation time to Resolver Group Assignment time. Could you please assist how to do this. We need to create a metric for each incident.
Eg:
Inc000001
Created and Assigned to SD -> 10 AM
SD Assigned to A Group -> 11 AM
A Group sent back to SD -> 12 PM
SD Assigned inc to B Group -> 1 PM
B Group sent back to SD -> 2 PM
SD Assigned to C Group -> 3 PM (5 hours is time to taken to find the right assignment group, it needs to be stored in metric/each incident)
C Group is the right resolver team and resolved the incident.
Above details are getting stored in Sys_audit table.
Below is the BR created in incident table, need help on bold and lines.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var syid = current.sys_id;
var grpid = current.assignment_group;
var inctime = current.sys_created_on;
var mttdtime;
gs.log('MTTD Calc '+ 'Sysid ' + syid + 'Assignment Group '+ grpid + 'Inc Created time ' + inctime);
var gr = new GlideRecord('sys_audit');
gr.addEncodedQuery('documentkey',syid);
gr.addEncodedQuery('newvalue',grpid);
gr.addEncodedQuery('fieldname','assignment_group');
gr.setLimit(1);
gr.query();
if (gr.next())
{
var agrptime = gr.sys_created_on.getDisplayValue();
gs.log('Assignment Grp Time ' + agrptime);
mttdtime = agrptime - inctime;
current.u_mttd = mttdtime;
gr.update();
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 08:33 AM
Getting the "touched" time is going to be more difficult because there's no field that tracks that. You're going to have to do a lookup on OTHER metric instances ... specifically the field tracking one for state and get the first instance of a state change to assigned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2022 08:09 PM
Querying on sys_audit is a fantastic way to make your instance unworkably slow.
Has anyone asked what itch this strange metric scratches? What do they think it tells them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 01:16 AM
Hi Robert,
Sure will keep them advised on instance performance.
If not sys_audit which other table can get us the metric they are looking for?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 05:25 AM
1) Use Metric Definitions to get the whole total age of the ticket.
2) Then use another Metric Definition (one exists OOB) to get the time per team.
Make a 3rd Metric Definition that queries for (1) and also the last metric instance generated for the task from Definition (2), and subtract 2 from 1.
Time to Last Team = Total Time - Time IN Last Team.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2022 05:04 AM
Hi Rob,
Sorry i am not able to locate the metrics. Could you please share the script if you have any.
Thanks
Ganesh