Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Metric not firing off for 1st updated by

Nickels
Tera Expert

I have a feeling that I may be missing something simple. I am trying to create a metric that will record the first person to update an incident. I will also be creating this on other tables but am starting with incidents first. I have created a metric against the Incident table and have it watching the Updates (sys_mod_update) field, the type is set to Script Calculation. Here is the script that I wrote for the this:

var mod = current.sys_mod_count;

if (mod == '1') {

createMetric();

}

function createMetric() {

        var mi = new MetricInstance(definition, current);

        if (mi.metricExists())

        return;

        var gr = mi.getNewRecord();

        gr.value = current.sys_updated_by;

        gr.calculation_complete = true;

        gr.insert();

}

       

I have tried multiple variations of this script and not having any good results. I started looking at the metric_events business rule today, so I am not sure if I need a new business rule to get this to start or not. Any advice you can offer is appreciated.

Thanks

-Chris

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

Metrics only work on audited fields. By default, the system does not audit records from system tables. To audit a system table, add it to the list of tables in the glide.ui.audit_deleted_tables property list.



You can also use a business rule to generate Metric's on system fields.


View solution in original post

5 REPLIES 5

Michael Fry1
Kilo Patron

Metrics only work on audited fields. By default, the system does not audit records from system tables. To audit a system table, add it to the list of tables in the glide.ui.audit_deleted_tables property list.



You can also use a business rule to generate Metric's on system fields.


Thank you for the reply. Sorry I hadn't gotten back to this discussion this month. I was sure I had read on other posts that this would be a way to accomplish what I was needing to do.



I am going to look into creating a business rule that would handle this metric. Thanks for the tip.



-Chris


I'm also wondering, do you know if there is documentation on using a business rule for a metric? I am trying to think about how I would go about setting this up and looking for ideas.



-Chris


No documentation using a business rule to capture a Metric that I'm aware.