Parent and child Incident relationship

Prabhat4
Tera Contributor

I want to establish Connection between parent incident and child incident (Parent incident field is present on incident form).

Whenever any incident is updated as parent of 'N' numbers of incident then all the child should be updated with worknotes that "INC***   has been updated as parent of this incident and for future updates please refer to parent incident". Moreover whenever i'll close the parent then all the child should also get close with same assigned to and assignment group values & with couple of more selected values. please advise how i can achieve this through Business rule.

Thanks

Prabhat

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

The business rule Update Child Incidents is the rule that updates Child incidents when the parent is updated or resolved. In order to achieve your requirement - ...whenever i'll close the parent then all the child should also get close with same assigned to and assignment group values & with couple of more selected values... - you'll have to modify the resolveChildIncidents section. See below:




function resolveChildIncidents() {


      var incident = new GlideRecord("incident");


      incident.addActiveQuery();


      incident.addQuery("parent_incident", current.sys_id);


      incident.addQuery("incident_state", "!=", IncidentState.RESOLVED);


      incident.query();


      var msg = "";


      while (incident.next()) {


              gs.print("Incident " + incident.number + ' resolved based on resolution of Parent Incident ' + current.number);


              incident.incident_state = IncidentState.RESOLVED;


              if (incident.close_notes.nil()) {


                      msg = "Close notes copied from Parent Incident";


                      if (current.close_notes.toString().indexOf(msg) == 0)


                              incident.close_notes = current.close_notes;


                      else


                              incident.close_notes = msg + ": " + current.close_notes;


              }


              incident.close_code = current.close_code;


              msg = "Resolved based on resolution of Parent Incident.";


              if (current.comments.toString().indexOf(msg) == 0)


                      incident.comments = current.comments;


              else


                      incident.comments = msg + " " + current.comments;


              incident.work_notes = current.work_notes;


//add new code here to set assignment group and assigned to


incident.assignment_group = current.assignment_group;


incident.assigned_to = current.assigned_to;


//add more values here as needed



              incident.update();


      }


View solution in original post

7 REPLIES 7

Hi Michael,



Entire Code in Bold is not working.



Thanks


Prabhat


How are you testing this? The code in bold will run when you Resolve the Parent Incident with the comments field blank.


You won't be able to change the Priority so change that to Urgency so you are copying down to the child - Impact & Urgency.


Thanks Michael,



I have got the idea, how it will work.



Thank you for your support.



regards


Prabhat