Work notes only copied to one task, not all
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi
My business rule isn’t working as expected. What am I missing? When I add work notes to Task 1, they only update Task 2, but Task 3 doesn’t get any of the notes. It seems to copy notes from Task 1 to Task 2, but Task 3 remains unchanged
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
your script is wrong to grab the value from work notes
Also are you sure there are 3 tasks and not 2?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @CarolMa6 ,
The trigger conditions are part of the problem — "Work notes changes" + "State is Closed Complete" means the rule only fires when a task is already closed and then gets a note added. That’s not a natural flow, so simplifying to just "Work notes changes" is a good debugging step.
But even if the condition is corrected, the script itself needs adjustment. current.getJournalEntry(1) only returns the latest note, and assigning directly to gr.work_notes overwrites the journal field instead of appending. That’s why only one sibling task gets updated and Task 3 stays unchanged.
(function executeRule(current, previous) {
var note = current.getJournalEntry(1); // latest work note
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.request_item);
gr.addQuery("number", "!=", current.number);
gr.query();
while (gr.next()) {
gr.setWorkflow(false); // prevent other rules from firing
gr.setJournalEntry("work_notes", note); // append properly
gr.update();
}
})(current, previous);
Key fixes:
- Use setJournalEntry("work_notes", note) instead of gr.work_notes = … so notes append correctly.
- Keep setWorkflow(false) to avoid recursive triggers.
- Adjust the condition to "Work notes changes" or "State changes to Closed Complete" depending on your business intent.
This way, all sibling tasks (Task 2, Task 3, etc.) under the same RITM will consistently receive the copied notes.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Best,
Anupam.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Viraj Hudlikar @Anupam1 @Rampriya-S
The code updates 'Task1' and 'Task2', but 'Task3' only receives work notes from 'Task1' and not from 'Task2'