Copy parent incident fields to child incidents when the parent is resolved

Roxi1
Tera Contributor

We have to Copy mandatory details to child incidents when parent incident is resolved.

Meaning, as per the OOB If a parent incident got resolved, child incidents will get auto resolved but without filling mandatory fields which result blank details in child. To avoid this we have to have one rule which will update the details as per parent.

if the child incident already have some value in it, then will have to remain and skip. Only update fields which doesn't have value in it (category, configuration item, business service, Assignment group).

This is the condition we used 

current.isValidRecord() && current.state.changesTo(IncidentState.RESOLVED) && (current.child_incidents > 0)

am assuming after business rule here, please suggest and can help with code if possible.

1 ACCEPTED SOLUTION

Sonu Parab
Mega Sage
Mega Sage

Hi @Roxi1 ,
In the after BR add below condition and script.
1] State changes to Resolved.

 

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

    // Add your code here
  var paINC = current.sys_id;

    var gr = new GlideRecord("incident");
    gr.addQuery('parent_incident', paINC);
    gr.query();
    if (gr.next()) {

        if (gr.category == "") {
            gr.category = current.category;
        }
        if (gr.cmdb_ci == "") {
            gr.cmdb_ci = current.cmdb_ci;
        }
         if (gr.business_service == "") {
            gr.business_service = current.business_service;
        }
        if (gr.assignment_group == "") {
            gr.assignment_group = current.assignment_group;
        }
         gr.update();
    }

})(current, previous);


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

Thank you

 

View solution in original post

1 REPLY 1

Sonu Parab
Mega Sage
Mega Sage

Hi @Roxi1 ,
In the after BR add below condition and script.
1] State changes to Resolved.

 

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

    // Add your code here
  var paINC = current.sys_id;

    var gr = new GlideRecord("incident");
    gr.addQuery('parent_incident', paINC);
    gr.query();
    if (gr.next()) {

        if (gr.category == "") {
            gr.category = current.category;
        }
        if (gr.cmdb_ci == "") {
            gr.cmdb_ci = current.cmdb_ci;
        }
         if (gr.business_service == "") {
            gr.business_service = current.business_service;
        }
        if (gr.assignment_group == "") {
            gr.assignment_group = current.assignment_group;
        }
         gr.update();
    }

})(current, previous);


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

Thank you