- 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 - 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.

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! 🙏