Copy custom my notes from child to parent work notes in scoped application

PavanJ
Tera Guru

As existing work notes and additional comments are not working as expected , created a custom field called my notes and created a after updated BR on custom filed to copy journal entry from child to parent

 

Initially i used below BR which coping all the wornotes fron child to parent

 

var latestWorkNotes = current.my_notes.getJournalEntry(-1);

      if (latestWorkNotes) {

        var parentRec = new GlideRecord('custom table');

        if (parentRec.get(current.parent)) {

            parentRec.my_notes += '\n\n' + current.number + '\n' +

                                  current.assignment_group.getDisplayValue() + '\n' +

                                  'Work notes added:\n' + latestWorkNotes;

            parentRec.update();

        }

    }

 

Then I tried gliding 'sys_journal_field' and executed using below Br which is working as expected, it is coping latest woodnotes to parent

 

var noteGR = new GlideRecord('sys_journal_field');

    noteGR.addQuery('element_id', current.sys_id);

    noteGR.addQuery('element', 'my_notes');

    noteGR.orderByDesc('sys_created_on');

    noteGR.setLimit(1);

    noteGR.query();

if (noteGR.next()) {

        var latestNote = noteGR.value;

        if (latestNote) {

            var parentRec = new GlideRecord('custom table');

            if (parentRec.get(current.parent)) {

                parentRec.my_notes += '\n\n' + current.number + '\n' +

                                      current.assignment_group.getDisplayValue() + '\n' +

                                      'Work notes added:\n' + latestNote;

                parentRec.update();

            }

        }

    }

 

Hope above scripts helps you

0 REPLIES 0