Autoclose related incidents when state is onhold, when Problem is resolved

Sriram17
Tera Contributor

Hi Team,

 

I need to Autoclose related incidents when state is onhold, when Problem is resolved

 

I have written After Insert or update Business rule on problem table.

Sriram17_0-1715228614936.png

 

Below is my code.

var incidentGr = new GlideRecord('incident');
        incidentGr.addQuery('problem_id', current.sys_id);
        incidentGr.addQuery('state', 3);
        incidentGr.query();

        // Loop through related incidents and close them
        while (incidentGr.next()) {
            incidentGr.state = 6;
            incidentGr.close_notes = "Automatically Resolved due to resolution of associated problem: " + current.number;
            incidentGr.update();
        }
 
 
Sriram17_1-1715228658026.png

 

Code is not working, Do I need to change anything?

 

 

 

1 REPLY 1

Brian Lancaster
Tera Sage

You should not have to do anything for this. Out of the box if the state is on hold and the on hold reason is awaiting problem it will automatically close the incidents.