want to chamge teh state in child Incident

aggarwaltan
Tera Contributor

When I add the parent incident to the related records of the child incident 

then the child incident state should become the same as the parent incident. 

Can you please help to create this in Client Script? 

 

2 REPLIES 2

Bhavya11
Kilo Patron

Hi @aggarwaltan ,

 

create Business rule on incident table when to run before update 

Bhavya11_0-1731903219163.png

add condition like below !current.parent.nil() && current.parent.changes();

and advance script will be

 

(function executeRule(current, previous /*null when async*/) {

	 if (!current.parent.nil() && current.parent.changes()) {
        var parentIncident = new GlideRecord('incident');
        if (parentIncident.get(current.parent)) {
            current.state = parentIncident.state; // Set child state to parent state
        }
    }

})(current, previous);

 

 

 

Please mark helpful & correct answer if it's really worthy for you.

 

Thanks,

BK

Community Alums
Not applicable

Please read the documentation on state syncing between parent and child incidents before adding in additional customization. 

 

https://www.servicenow.com/docs/bundle/xanadu-it-service-management/page/product/incident-management...