Copy Child Incident Worknotes to parent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2025 04:40 AM - edited ‎04-05-2025 04:43 AM
Hello Team,
I would like to copy the latest work notes from a child incident to its parent incident. I have configured an "After Insert and Update" Business Rule that runs only when the parent incident is not empty and the work notes field is changed.
In the Business Rule, I have written a script to update the work notes of the parent incident. However, I'm facing an issue where I'm unable to access the latest work note—it is returning as undefined.
Could you please guide me on how to correctly retrieve the latest work note in this scenario?
Thank you!
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage(gs.isInteractive());
var parentInc = new GlideRecord('incident');
parentInc.addQuery('sys_id', current.parent_incident); // Get parent incidents of the current record
parentInc.query();
gs.addErrorMessage("Line 8");
while (parentInc.next()) {
gs.addErrorMessage('If block'+current.getJournalEntry(-1));//giving undefined
parentInc.work_notes = current.getJournalEntry(1); // Copy the latest journal entry to parent
parentInc.setWorkflow(false);
parentInc.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2025 05:19 AM - edited ‎04-05-2025 08:07 AM
Hello @Mark Wood ,
Please replace
parentInc.work_notes = current.getJournalEntry(1)
With this:
parentInc.work_notes = current.work_notes.getJournalEntry(1)
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2025 07:47 AM - edited ‎04-05-2025 07:50 AM
Hi @Mark Wood ,
You missed the name of field while assigning the value to the work notes of your parent incident. As correctly mentioned by @Robert H
Use this :
parentInc.work_notes = current.work_notes.getJournalEntry(1);
setWorkflow(false) - this will stop the trigger of any other workflow,flow,be to trigger once your work notes is updated in incident table. So use it is really required as per use case.
If my response helped, please mark my response as solution accepted and hit thumbs up.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2025 07:43 AM
Hi @Mark Wood ,
Glad that my response was helpful.
Please also mark my response as solution expected so that it help future reader as well.
Regards,
Rohit