We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

- If the incident is re-opened while in a resolved state, a new metric created

sujaykm
Tera Contributor

On resolve state after reopen the incident.

- If the incident is re-opened while in a resolved state, a new metric should be created

can you help me on this

4 REPLIES 4

Dr Atul G- LNG
Tera Patron

Hi @sujaykm 

Whenever the state changes, a metric record should be automatically created to track the change.

 

You can put a script in metric that applies only for Resolved state.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

if (current.state == 6) {
    createMetric();
}

function createMetric() {
    var gr = mi.getNewRecord();

    gr.start = current.sys_created_on;
    gr.end = current.sys_updated_on;

    var start = new GlideDateTime(gr.start);
    var end = new GlideDateTime(gr.end);
    gr.value = "Test";
    gr.duration = gs.dateDiff(gr.start, gr.end);
    gr.calculation_complete = true;
    gr.insert();

}
 
currently i am using this script, can u modify in this script
for this -- If the incident is re-opened while in a resolved state, a new metric created

Ankur Bawiskar
Tera Patron

@sujaykm 

is that not working with OOTB metric?

You can see if State is changed to Open incident_state is also changed or not

If yes then OOTB metric definition will handle this

If not then update it so that metric takes care of this

55.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Mark Manders
Giga Patron

https://www.servicenow.com/community/developer-forum/if-the-incident-is-re-opened-while-in-a-resolve...


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark