How to Close child ncidents

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2023 12:44 AM
Create an incident say A. Create two more incidents say B & C. Associate B & C as child incidents to incidents A. If Incident A is closed, child incidents B & C should be closed automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2023 08:05 AM
Hello,
You need to write async business rule on incident table like below and add condition "state is closed".
var grinc=new GlideRecord('incident');
grinc.addQuery('parent_incident',current.sys_id);
grinc.query();
while(grinc.next())
{
grinc.setValue('state',7);
grinc.update();
}
Please mark my answer as helpful/correct if it helps you.
Regards,
Namrata

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2023 09:51 AM
Hi @Community Alums ,
Create a BR and code as below
var inc=new GlideRecord('incident');
inc.addQuery('parent_incident',current.sys_id);
inc.query();
while(inc.next())
{
inc.state = 7;
inc.incident_state =7;
inc.comments = "Parent closed : "+current.number;
inc.active = false;
inc.update();
}
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2023 10:54 AM
Hi,
This could also be done with a simple flow, no scripting required.
Example below.
I would recommend to go the non-scripting approach whenever possible.