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

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

Gopal14_1-1715229212636.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();
}

Gopal14_0-1715229186164.png

 



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

 

@Community Alums @Voona Rohila @Dr Atul G- LNG 

1 REPLY 1

Bhavya11
Kilo Patron

Hi @Gopal14 

 

To solve this create the after update Business rule on Problem table.

 

Bhavya11_0-1715230880158.png

 

advanced script part: 

Bhavya11_1-1715230912863.png

 

 

then resolve the Problem it will close the Associated incidents. before that make note that there is already on OOO  Business rule called "SNC - ITIL - Update Related Incidents" so you need to run your Business rule after this as your closing the Incident so.

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

Thanks,

BK