Metric Definition Triggering

Shravan Gatty
Giga Guru

Hi everyone,

I'm working on a requirement to generate a report that tracks:

The number of touches (state changes) for HR cases, specifically when the state transitions from Work in Progress to Closed Complete, Cancelled, or Incomplete.
The number of touches for changes in Assignment Group and HR Service.
My Approach:
I've started by creating Metric Definitions for each of the three conditions: state, assignment group, and HR service. I successfully created the metric definition for the state change, but it doesn't seem to trigger even after the condition is met (screenshot attached).

Plan:
Once all metric definitions are in place, I plan to create a Database View that includes sn_hr_core_case, metric_instance, and metric_definition.
I’ll use this view to build the report.
My Doubt:
How can I show the number of touches in the report? Do I need to create a custom field to store and display the count of touches, or is there a better way to achieve this using out-of-the-box capabilities?.
also in metric definition where i am going wrong i think the logic is correct what i have provided there but its not triggering.


Any guidance or best practices would be greatly appreciated!

Thanks in advance!





#hrsd #servicenow 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Shravan Gatty 

did you compare yours against the OOTB incident metrics for those fields?

Why are you using script?

For State, Assignment Group you can use type as "Field value duration"

AnkurBawiskar_0-1752819712955.png

 

Check the script in few of the OOTB ones

AnkurBawiskar_1-1752819753928.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar – Thanks for your response! Yes, I’ll use the Field Value Duration type for tracking changes in HR Service and Assignment Group.

For the State field, can I also use the Field Value Duration type and include a script in the metric definition to handle the specific transitions?(or do i need to change the type to script calculation)

Additionally, I plan to create a Database View that joins sn_hr_core_case, metric_instance, and metric_definition.

One more question: since the metric instance will capture how many times the state has changed, how can I display the number of touches as a numeric value in the report? Do I need to create a custom field to store and show this count, or is there an out-of-the-box way to achieve this?

@Shravan Gatty 

please check how the OOTB ones are configured.

yes once that is ready you can use metric_instance table for database view join.

For this as well you will see few OOTB database views.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader