Report for priority changes to capture only when priotity is changed

Gaurav Vaze
Kilo Sage

hello,
I have a requirement to create a report on incidents priority change
for this, I have created a metric definition that is on the priority field
initially, it was as field value duration but was capturing the newly created incidents too.
My requirement is that only those incidents should be captured for the priority is CHANGED, not the incidents which have the priority set during creation
here is the SS of what I have done

GauravVaze_0-1714989530997.png

 


I'm not getting results
help will be really appreciated
Thank you in advance!

1 ACCEPTED SOLUTION

Gaurav Vaze
Kilo Sage

Guys exciting news, I found a way to do the same
here is the breakdown of the same

step1] create a metric definition on the priority field

  • Navigate to Metric definitions (metric_definition)
    GauravVaze_0-1715154864105.png

     

  • click on new
  • choose a table as Incident
  • choose type as field value duration
  • choose field as Priority

    GauravVaze_1-1715155004476.png

     

step 2] Create a script include

  • under system definition, navigate to script include and click on new
  • give the appropriate name and paste the following code(note the name of SI will be different  in your case)

    GauravVaze_3-1715155373481.png

     

  • save

step 3] Create a report on the incident_metric table

  • navigate to create a new inside report
  • give title, choose table as incident_metric
  • choose type as list
  • choose filter as: definition is [your definition name create din first step] and sys_id(inc_sysid) is one of the 
    javascript: new (your Si name here followed with ()).(your function name inside SI followed with ())
    (example: javascript:new ICgetMetricInstances().createMetric();)
    GauravVaze_4-1715155508234.png

     



    Note: this will give you those incidents for which priority is changed actually 

View solution in original post

3 REPLIES 3

Vishwa Pandya19
Mega Sage

Hi Gaurav,

 

Your condition in the if condition is invalid.

Please use below.

if(current.priority.changes()){
createMetric()
}

 

If my answer helps you in any way please mark it as correct or helpful.

I see there was a Typo
however, changing to the one you gave also resulted in none
is my script missing something

Gaurav Vaze
Kilo Sage

Guys exciting news, I found a way to do the same
here is the breakdown of the same

step1] create a metric definition on the priority field

  • Navigate to Metric definitions (metric_definition)
    GauravVaze_0-1715154864105.png

     

  • click on new
  • choose a table as Incident
  • choose type as field value duration
  • choose field as Priority

    GauravVaze_1-1715155004476.png

     

step 2] Create a script include

  • under system definition, navigate to script include and click on new
  • give the appropriate name and paste the following code(note the name of SI will be different  in your case)

    GauravVaze_3-1715155373481.png

     

  • save

step 3] Create a report on the incident_metric table

  • navigate to create a new inside report
  • give title, choose table as incident_metric
  • choose type as list
  • choose filter as: definition is [your definition name create din first step] and sys_id(inc_sysid) is one of the 
    javascript: new (your Si name here followed with ()).(your function name inside SI followed with ())
    (example: javascript:new ICgetMetricInstances().createMetric();)
    GauravVaze_4-1715155508234.png

     



    Note: this will give you those incidents for which priority is changed actually