Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Metric to measure time incident is assigned to person to time it is resolved

SandyL83
Tera Guru

Hello,

I am trying to create a metric to  measure the time from when an incident is assigned to a person (incident state changes to "Assigned") and the time the incident is Resolved (incident state changes to Resolved). 

I have the following code, but it seems to me measuring from open to resolve, not assigned to resolved. 

(Resolved= -3, Assigned is -3). Any ideas?

 

    var s = current.state;
    var mi = new MetricInstance(definition, current);
    if (mi.metricExists()) {
      if (s == 6) {
          mi.endDuration();
      }
    } else if (s == -3) {
        mi.startDuration();
    }
1 ACCEPTED SOLUTION

Ranjit Nimbalka
Mega Sage

Hi @SandyL83 ,

 

You can refer this https: //www.servicenow.com/community/itsm-forum/incident-metric-calculate-time-between-first-assigned-to-unt...

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

Regards,

Ranjit

 

View solution in original post

6 REPLIES 6

Bert_c1
Kilo Patron

Hi SandyL83,

 

Is the 'u_time_assigned' field a Date/Time field? Your script looks good.  Is there a condition defined on the BR? Maybe add:

 

gs.addInfoMessage("BR previous.assigned_to = " > previous.assigned_to + ", current.assigned_to = " + current.assigned_to + "."); before you "if" statement and test, a message will be added.

 

On Insert, 'previous' object will be undefined, You may want to run that BR on Update too, if there is no assigned_to value when the incident is created.

Thank you!!!!! Changing it to "Update" did the trick! As always, you rock!