Amit Gujarathi
Giga Sage
Giga Sage

Hi All,

Hope you are doing fine.
In this tutorial, we will be looking into Metric Definition in ServiceNow.We will be looking into the following points in ServiceNow :
1. What is the Metric definition in ServiceNow
2. What is the benefit of ServiceNow Metric Definition
3. How we can create ServiceNow Metric Definition
4. ServiceNow Metric Definition demo

Let’s first try to understand what is Metric in ServiceNow
Defined metrics can track how long an audited field holds a certain value.

For instance, a metric can track how long an incident is assigned to an individual, or how long an incident is in the state Active.

Please like, follow subscribe if you like the video to get regular updates on the upcoming videos.

Regards,
Amit Gujarathi
(Technomonk)

Comments
laxmi1509
Tera Contributor

In Metric Definition i wrote one script but created data is coping updated data because of that duration time is showing 0.

Script is:

var type = current.u_type;
if (type == 'HRIS') {
createMetric();
}

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

var gr = mi.getNewRecord();
gr.start = current.sys_created_on;
gs.info("-&End date: " + current.getDisplayValue('sys_updated_on'));
//gr.end = new GlideDateTime(current.sys_updated_on);
gr.end = current.sys_updated_on;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();

}

laxmi1509_0-1699772272608.pnglaxmi1509_1-1699772273214.png

 

laxmi1509
Tera Contributor

In Metric Definition i wrote one script but created data is coping updated data because of that duration time is showing 0.

Script is:

var type = current.u_type;
if (type == 'HRIS') {
createMetric();
}

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

var gr = mi.getNewRecord();
gr.start = current.sys_created_on;
gs.info("-&End date: " + current.getDisplayValue('sys_updated_on'));
//gr.end = new GlideDateTime(current.sys_updated_on);
gr.end = current.sys_updated_on;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();

}

laxmi1509_0-1699772411710.png

 

 

jmdavid
Mega Explorer

Hi, is it possible to dive into sub records?
For example, I want to calculate the difference between an alert creation and the associated incident assignation.

 

Is it possible?

Thanks.

Version history
Last update:
‎10-11-2022 02:33 AM
Updated by:
Contributors