- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 12:00 AM
Hi all so i have been working on this scenario where i have to post work notes of my parent incident to my child incident decription field for this i have written a br for before update of my child incident and wrote this code within my br
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:06 AM
business rule script will be like this
(function executeRule(current, previous /*null when async*/) {
var pa = current.parent_incident;
var arr = [];
var gr = new GlideRecord("sys_journal_field");
gr.addQuery("element", "work_notes");
gr.addQuery("element_id", pa);
gr.query();
while(gr.next()) {
var val = gr.value.toString();
// Optional: skip empty values, or filter by element = 'work_notes' if needed
arr.push(val);
}
// Join with newlines for readability
current.description = arr.join('\n\n');
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2025 10:10 PM
Hi @sasharma815 ,
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Future readers with similar kind of question will easily find out. Thanks in advance!
Regards,
Bhimashankar H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:01 AM - edited 07-24-2025 08:24 AM
Hi @sasharma815 ,
The issue you are facing is related to how you're assigning an array to the current.description field, which expects a string, not an array or complex object. The "org.mozilla.javascript.NativeArray@..." value is just the JavaScript engine's toString() representation of your array object, not the contents.
Try below code:
First you need to push all the work notes into array then, then by joining next lines update to description field of incident.
(function executeRule(current, previous /*null when async*/) {
var pa = current.parent_incident;
var arr = [];
var gr = new GlideRecord('sys_journal_field');
// Only fetch work notes from the parent incident
gr.addQuery('element_id', pa);
gr.addQuery('element', 'work_notes'); // Better scope: get only work notes
gr.orderBy('sys_created_on'); // To keep correct order, optional
gr.query();
while (gr.next()) {
arr.push(gr.value.toString());
}
// Combine all parent work notes into a single string with line breaks
current.description = arr.join('\n');
})(current, previous);
As
Use gr.orderBy('sys_created_on') to maintain chronological order if needed.
Since you're changing current.description on a before update Business Rule, this will save the concatenated work notes into the child incident's description before the record saves.
Avoid calling gs.addInfoMessage() in a Business Rule as it shows only in UI and may clutter logs.
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:06 AM
business rule script will be like this
(function executeRule(current, previous /*null when async*/) {
var pa = current.parent_incident;
var arr = [];
var gr = new GlideRecord("sys_journal_field");
gr.addQuery("element", "work_notes");
gr.addQuery("element_id", pa);
gr.query();
while(gr.next()) {
var val = gr.value.toString();
// Optional: skip empty values, or filter by element = 'work_notes' if needed
arr.push(val);
}
// Join with newlines for readability
current.description = arr.join('\n\n');
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2025 10:10 PM
Hi @sasharma815 ,
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Future readers with similar kind of question will easily find out. Thanks in advance!
Regards,
Bhimashankar H