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

If the incident state changes to resolved, new metric has been creating, 
If the incident is re-opened while in a resolved state new metric should create

 

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();

}
right now i am using this code for "If the incident state changes to resolved, new metric has been creating,"
 
can u modify the code for "If the incident is re-opened while in a resolved state new metric should create" this also
1 REPLY 1

Mark Manders
Giga Patron

This is already taken care of OOB. Every state change creates a new metric record.

 

Also: posting the same question twice is against Community guidelines:

https://www.servicenow.com/community/community-resources/servicenow-community-code-of-conduct-for-al...
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