Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

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
Giga 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();
}

 

 

View solution in original post

4 REPLIES 4

anubhavritolia
Giga 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();
}

 

 

@Chandra31 

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

Did you explore that?

Saurav11
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();
}