Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Update the 'Parent Incident' field on child of child Incident

Delapan
Tera Contributor

If you are trying to link a parent incident under the child Incident, the child incidents should be re-parented to the Incident you are on.

Example: If you are going to add INC2 as child Incident of INC1, but INC2 has 2 child Incidents (INC3 & INC4). When you link INC2 as a child to INC1, then INC3 and INC4 should get re-populated to INC1.

 

How can we achieve this.

Thanks in advance. 

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron

Hi @Delapan ,

 

You can do it with the below business rule :

 

 

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

    if (current.parent.nil() || current.parent == previous.parent) {
        return; }

    var childIncidents = new GlideRecord('incident');
    childIncidents.addQuery('parent', current.sys_id);
    childIncidents.query();
    while (childIncidents.next()) {
        childIncidents.parent = current.parent; 
        childIncidents.update(); 
    }

})(current, previous);

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

1 REPLY 1

Sohail Khilji
Kilo Patron

Hi @Delapan ,

 

You can do it with the below business rule :

 

 

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

    if (current.parent.nil() || current.parent == previous.parent) {
        return; }

    var childIncidents = new GlideRecord('incident');
    childIncidents.addQuery('parent', current.sys_id);
    childIncidents.query();
    while (childIncidents.next()) {
        childIncidents.parent = current.parent; 
        childIncidents.update(); 
    }

})(current, previous);

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect