Copy work notes from child to parent incident

Chandra31
Tera Contributor

How to copy work notes from child to parent.

@Ankur Bawiskar 

1 ACCEPTED SOLUTION

AnubhavRitolia
Mega Sage
Mega Sage

Hi @Chandra31 

 

Create a Business Rule as After Update with below Condition:

Work Notes Changes

 

var lastWorkNote = current.work_notes.getJournalEntry(-1);

var parentInc = new GlideRecord('incident');
parentInc.addQuery('sys_id',current.parent_incident);
parentInc.query();

if(parentInc.next())
{
parentInc.work_notes = lastWorkNote;
parentInc.update();
}

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

View solution in original post

4 REPLIES 4

AnubhavRitolia
Mega Sage
Mega Sage

Hi @Chandra31 

 

Create a Business Rule as After Update with below Condition:

Work Notes Changes

 

var lastWorkNote = current.work_notes.getJournalEntry(-1);

var parentInc = new GlideRecord('incident');
parentInc.addQuery('sys_id',current.parent_incident);
parentInc.query();

if(parentInc.next())
{
parentInc.work_notes = lastWorkNote;
parentInc.update();
}

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

@Chandra31 

you can easily achieve this using flow designer with no script.

Did you explore that?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

You can write a after update BR on incident table with condition that parent incident is not empty 

 

Saurav11_0-1668772606166.png

 

And use the below script:-

 

 

(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord('incident');
(gr.get(current.parent_incident))
{
gr.work_notes=current.work_notes.getJournalEntry(1);
gr.update();
}
})(current, previous);

 

  

Please mark my answer as correct based on Impact.

Aman Kumar S
Kilo Patron

Hi @Chandra31 ,

You need to create an After Update Business rule

Filter condition as:

Parent Incident - is not empty

Work notes - Changes

 

Script as:

var parentIncGR = new GlideRecord('incident');
if(parentIncGR.get(current.getValue("parent_incident")){
     parentIncGR.work_notes = "Update from Child Incident " + current.getValue("number") + " : " +current.work_notes;
     parentIncGR.update();
}

 

 

Best Regards
Aman Kumar