Checking the count of each state of a case it has been

Anisha1530
Tera Contributor

Can we make count for each state of a case is in like NEW, open, in progress , resolved . For ex :- If a case was in progress it went to awaiting info and again went back in progress. So there is 2 times the case was in in progress can we show the case count on our case form

2 REPLIES 2

Sanjay191
Tera Sage

Hello @Anisha1530 

Yes you can do by using before update  business rule to update the count for the respective state changes so you need to create count field for the state count and it will update whenever state changes and write the BR on respective table and also you can use the switch condition for this.

logic should be
if(current.state == 'new'){

current.new_count += 1;

}

if(current.state == ''open"){

current.open_count += 1;

}

if(current.state == ''in progress"){

current.inprogress_count += 1;

}

if(current.state == ''resolved "){

current.resolved_count += 1;

}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You




Uncle Rob
Kilo Patron

Yes, with metrics and metric instances.   
Look for this section on your navigator bar.  It can be hard to search for given how many times ServiceNow uses the term "metrics".  You could also access via table names:  metric_definition & metric instance
UncleRob_0-1746790154709.png


A metric definition allows you to pick a column to track.  For every change to the field, it creates a metric instance record.  See in this case it shows you the start/end/duration of each of the states for INC0010078.

UncleRob_1-1746790408234.png

 

There's a ton of OOB definitions for the INCIDENT table and an OOB Database View that brings together Incidents and Metrics for the Incidents.  You can use those as examples.