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.

Calculate state duration

Rishabh Dev Kha
Tera Contributor

Hi,

 

I want to calculate total time for which incident is on "In Progress" state how can  I do it.I tried it with metric but it is creating seperate record if state changes from to another.

5 REPLIES 5

Saurabh Gupta
Kilo Patron

Hi,

You can use metric table in reporting module.
Below is one similar report.

 

SaurabhGupta_1-1673129286853.png

 


Thanks and Regards,

Saurabh Gupta

AndersBGS
Tera Patron
Tera Patron

Hi @Rishabh Dev Kha ,

 

Have you looket into SLA breakdown as a possibility? https://docs.servicenow.com/en-US/bundle/tokyo-it-service-management/page/product/service-level-mana...

if my answer helped for a answering your question, please my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

this worked...here is the filter I used....attached.Incident state Duration.jpg

-O-
Kilo Patron

Easiest is to configure a new Metric Definition. You can find it in the ServiceNow Navigator under Metrics -> Definition. There already is a Metric Definition for the Incident state field. You could create a new one but for field State. After that you can report on it as @Saurabh Gupta suggests.

Note that this will not create records for past incidents but only for future incidents. If you also need historic data, your accessible option is generating it using a Fix script that leverages the sn_hw.HistoryWalker() API - it enables accessing all records (with auditing enabled) with each of that record's state. You would need to create a script that loops through each incident then loops through each update of individual incidents and - of course - compute the length of state and save it as a Metric Instance record.

Below is something I just created (by copying the existing Metric for field Incident state) - you can see that it already captured values as I played with an incident in my PDI:

2023-01-08-1.png