Incident "Assigned To" metric by "State"

DavidChazin
Kilo Explorer

Hello,

I'm struggling with creating an incident metric definition that creates one record per Assignment Group per State. So, I need one metric instance record every time a State or Assignment Group changes -- for example:

INC Number--Queue---------State------------------Business Hours
INC0019876 SharePoint-----New-------------------1.1
INC0020302 Quality Mgmt--New-------------------0.5
INC0020302 Quality Mgmt--Active----------------11.6
INC0020325 SharePoint-----New-------------------2.2
INC0020325 SharePoint-----Active-----------------5.2
INC0020325 SharePoint-----Awaiting User Info---10.1
INC0020325 SharePoint-----Active-----------------1.4
INC0020450 Compliance----New-------------------0.5
INC0020450 Compliance----Active----------------33.1

Thanks for your help.

--David Chazin

7 REPLIES 7

dada50
Kilo Explorer

I believe what you explaining can be done.
You will need will need to create Metric definition (see below) with Script. I have not clearly understood your requirement, but you may need to create few Metric definitions to accomplish your requirements.

Metrics -> Definitions -> New

You will need to setup conditions when to capture the metrics. Like in the example below, when the assignment group changes after first assignment it captures the metrics (it is sort of escalation point for us, when ticket got escalated to new group)

After the Metric definition is setup and working properly, the data will be available in the database views incident_metric (Database Views -> incident_metric)

I hope it helps, Faisal

// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
var s = current.assignment_group;
if (s.changes && current.sys_mod_count != 0)
createMetric();

function createMetric() {
var mi = new MetricInstance(definition, current);
// if (mi.metricExists())
// return;

var gr = mi.getNewRecord();
gr.start = current.sys_created_on;
gr.end = current.sys_updated_on;
gr.value = current.assignment_group.getDisplayValue();
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}


Thanks, Faisal.

Your approach looks like it will work well -- and thanks for the actual code. I will implement it as soon as I finish reporting on the past months.

Since the metrics you describe were not running in July and August, I am exporting a list to Excel, and will write VBA code to create the report. If I get the new metrics in place before the end of this month, I will be able to use them for reporting directly out of ServiceNow starting with October.

Meanwhile, in order to do First Call Resolution reporting on past months, I created a report on the Incident Metric [incident_metric] view. I filtered the resulting list so it contains only the Incident State Duration, Assignment Group and Assigned to Duration records. They contain all the information I will need to do my reporting. Once I get the list into Excel, it will be easy to write some VBA code to loop through the rows that pertain to each individual Incident ticket, gathering the information I will need for each row in my report.

For example, I can loop through all the Assignment Group records for a given ticket, to make sure the ticket was not reassigned to another queue. Similarly, I can loop through the Assigned To records for the ticket to see if the ITIL-user remained the same throughout the life of the ticket.....

Thanks again.

--David Chazin


chandu5434
Kilo Contributor

Hello,

 

I have the same question. But my case is creating metrics for a table where metrics should be calculated in below states.

 

 

review to approval,

review to denial,

and also table tasks states such as 

new to completed,

duration for each state,

age metric.