The CreatorCon Call for Content is officially open! Get started here.

Coping of work notes and comments from parent incident ticket to child incident ticket?

Sanchita Tiwar1
Kilo Contributor

When we are creating any child ticket   under the parent incident , then all the work notes and comments of parent incident should copy to the activity log of child incident.

3 REPLIES 3

Deepa Srivastav
Kilo Sage

Hi Sanchita,



You can create business rule for this.Refer the OOB BR 'Update Child Incidents' for this ...adjust your conditions according to your requirement.



Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.


amlanpal
Kilo Sage

Hi Sanchita,



There is a OOB Business Rule available in the Incident table named 'Update Child Incidents' This business rule works after update and also updates the Work notes and Comment to the Child Incident.


Please do the required modification in the script and condition according your requirement and create a new Business Rule before Insert as per your query.



I hope this helps.Please mark correct/helpful based on impact




derekmacdonald
Tera Contributor

Here's a bit of code that might help. (from the oob code, your issue may be that you created a new parent incident field that needs to be updated)





updateChildIncidents();


function updateChildIncidents() {


  updateChildren('comments', 'Comment copied from Parent Incident');


  updateChildren('work_notes', 'Work note copied from Parent Incident');


  }



}




function updateChildren(fieldName, msg) {


  msg = gs.getMessage(msg);


  var rec = new GlideRecord("incident");


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


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


  rec.addActiveQuery();


  rec.query();


  while (rec.next()) {


  var fieldRawValue = current.getValue(fieldName) + '';


  var fieldValue = fieldRawValue.trim();


  if (!fieldValue || fieldValue.length <= 0)


  return;


  if (fieldRawValue.indexOf(msg) == 0)


  rec[fieldName] = fieldRawValue;


  else


  rec[fieldName] = msg + ": " + fieldRawValue;


  rec.update();


  }


}