Calculating Time in Open and Work in Progress State

Kristen William
Kilo Explorer

I have been tasked with creating metrics for measuring the length of time a ticket is in the "open" state "work in progress" state, and "pending" state. I see there is an out of box metric for calculating the length of time a ticket is in "pending". Is there a way to calculate "open" and "work in progress" as well? Thanks!

3 REPLIES 3

Community Alums
Not applicable

Hello @Kristen Williams 

Yes, it is possible using metrics "Script Calculation" type. PFB screen shot for incident with work in progress state. 

find_real_file.png

 

Similarly  you can create for open state as well.

 

If my answer helped you in any way, please then mark it as Correct and helpful.

 

Regards,

Akshay

Community Alums
Not applicable

Updated - 

Hi again

Sorry I forgot to paste source code. Here it is -

 

var s = current.incident_state;
if (s == 2) // if state is In Progress
  createMetric();

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

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

 , 

Regards,

Akshay

Community Alums
Not applicable

Hey  @Kristen Williams ,

Didn't hear back on this.

Is your issue resolved by my answer? If yes, feel free to mark correct as well, so it will be helpful for others looking for similar query.

If not let us know your issue so we can help you.

 

 


Thanks
Akshay Kangankar