Current State Duration

Amy Lind1
Giga Guru

Greetings!  

I'm posting because I'm certain this data has to have been collected by some of you out there.   I've several ideas in my head, but why reinvent the wheel if I poll you all?  

So, what we need is the and that is the current state duration.   We are using the standard metrics to pull how long an Incident was in each state in the past, however the data we are missing is being able to report how long Incidents have been sitting in the state they are currently in.   Up to this point, we've been exporting the data and creating our own reports to calculate the duration from which the Incident was last updated to the current date, which is less than ideal.  

Any thoughts/suggestions on how we can accomplish this?

Many thanks!   Amy

1 ACCEPTED SOLUTION

Uncle Rob
Kilo Patron

This can come with a bit of load consequence, but its the only way I know of to accomplish it.


We had a similar requirement.   They wanted all active calculations to be "as up to date as possible" rather than being null until the calculation completed.



I created a scheduled job that runs every 12 hours.   It checks all Metric Instances where calculation_complete = false and updates their duration field.   If I were to do it over again, I might add a field to the Metric Definition table which governs whether or not we want the metric instances caught in this script (its essential for some metrics, but not for others).



Scheduled Job:   "Update Continuous Duration Metrics"


var inst = new GlideRecord("metric_instance");


inst.addQuery('definition.type','field_value_duration');


inst.addQuery('calculation_complete',false);


inst.query();



while(inst.next()){


  inst.duration = gs.dateDiff(inst.start.getDisplayValue(), gs.nowDateTime());


}


View solution in original post

6 REPLIES 6

Start a new thread and I'll answer the question there.

 

Hi Robert, i started a new thread here:

https://community.servicenow.com/community?id=community_question&sys_id=525d4147dbb2c8d813b5fb2439961935

thanks again