6. Copy the work notes of child to its Parent.

purnendu
Tera Contributor

Copy the work notes of child to its Parent.


I have written this code:--|


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

    // Add your code here
    var incGr = new GlideRecord('incident');
    incGr.addQuery('parent', current.parent.sys_id);
    incGr.addQuery('state', '!=', '7');
    incGr.query();
    while (incGr.next()) {
      incGr.work_notes = current.work_notes.getJournalEntry(1);
        incGr.update();
    }

})(current, previous);


after update

Condition : Worknote changes.
 
but i am not getting the desired result.

Thanks in advance.
1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@purnendu Please update your script as follows.

 

 

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

    // Add your code here
    var incGr = new GlideRecord('incident');
    incGr.addQuery('sys_id', current.parent.sys_id); //fetch the parent incident matching with sys_id
    incGr.addQuery('state', '!=', '7');
    incGr.query();
    while (incGr.next()) {
      incGr.work_notes = current.work_notes.getJournalEntry(1);
        incGr.update();
    }

})(current, previous);

 

View solution in original post

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@purnendu Please update your script as follows.

 

 

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

    // Add your code here
    var incGr = new GlideRecord('incident');
    incGr.addQuery('sys_id', current.parent.sys_id); //fetch the parent incident matching with sys_id
    incGr.addQuery('state', '!=', '7');
    incGr.query();
    while (incGr.next()) {
      incGr.work_notes = current.work_notes.getJournalEntry(1);
        incGr.update();
    }

})(current, previous);

 

@Sandeep Rajput Thank you so much Sandeep.

@purnendu Thanks a lot for accepting the response. Please mark it helpful too.