The Zurich release has arrived! Interested in new features and functionalities? Click here for more

child security incident cannot be closed when parent security incident is active

Siva_Prasad
Tera Contributor

Parent security incident open dependency ensuring child Security Incidents cannot close while parent IT incidents remain active without proper resolution coordination Wanted to create business rule for this but not getting properly, any help would be helpful

5 REPLIES 5

SP22
Mega Sage
Mega Sage

Hello @Siva_Prasad,

Name: Prevent Closure if Parent Incident Active
Table: Security Incident (sn_si_incident)
When: Before Update
Filter: [State] [changes] [to] [Closed] (or your resolved state value)

Script: 

// Get the parent incident reference
var parentIncident = current.parent_incident; // Replace with your field name

if (parentIncident) {
    var parentGr = new GlideRecord('incident'); // IT Incident table
    if (parentGr.get(parentIncident)) {
        // Check if parent is not closed/resolved
        if (parentGr.state != 6) { // 6 = Closed (default, check your state values)
            gs.addErrorMessage('Cannot close this Security Incident while the parent IT Incident is still active.');
            current.setAbortAction(true);
        }
    }
}


If this helped to answer your query, please mark it helpful & accept the solution.


Thanks
Santosh.p

Siva_Prasad
Tera Contributor

the solution is working but in a different way , like when a child incident is closing the automatically parent is closing ,

 

Hello @Siva_Prasad 

// Only check if this is a parent incident (has children)
var childGr = new GlideRecord('sn_si_incident');
childGr.addQuery('parent', current.sys_id); // 'parent' is the OOTB reference field for parent incident
childGr.addQuery('active', true); // Only active children
childGr.query();

if (childGr.hasNext()) {
    gs.addErrorMessage('Cannot close this Security Incident while child Security Incidents are still active.');
    current.setAbortAction(true);
}

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks
Santosh.p

M Iftikhar
Mega Sage

Hi @Siva_Prasad

 

To prevent a parent security incident from closing while child security incidents are still active, you can create a before update Business Rule on the Security Incident (sn_si_incident) table. Configure this rule to trigger when the State changes to Closed. In the script, perform a GlideRecord query to check for any child incidents (parent = current.sys_id) that are still active (active = true). If the query finds any active child incidents, use current.setAbortAction(true) to stop the update and gs.addErrorMessage() to inform the user that all child incidents must be closed first. 

 

Hope this helps!

 

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.