Copy RITM Worknotes to SCTASK - ServiceNow Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 10:23 PM
Hi Team ,
I have to whcih ever we have updated in additonal comments the same should be copied in sctask worknotes only a particular catalog item
I have configured After update BR for
(function executeRule(current, previous /*null when async*/) {
var latestComment = current.comments.getJournalEntry(1); // get latest additional comment
var taskGr = new GlideRecord('sc_task');
taskGr.addQuery('request_item', current.sys_id);
taskGr.query();
while (taskGr.next()) {
taskGr.work_notes = "Customer Comment from RITM:\n" + latestComment;
taskGr.update();
}
})();
Test Reults -
comments were not copied ritm to sctask
can any one please help me what was the mistake here .
@Ankur Bawiskar could you pllease help me here on my mistake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 10:55 PM
Hello @nameisnani,
Try a before business rule add condition as current.comments.changes()
and try using this script
(function executeRule(current, previous /*null when async*/) {
// Check if the catalog item matches the desired one
if (current.cat_item.name == 'Your Catalog Item Name') {
// Get all open catalog tasks related to this RITM
var task = new GlideRecord('sc_task');
task.addQuery('request_item', current.sys_id);
task.addQuery('state', '!=', 3); // Closed
task.query();
while (task.next()) {
// Copy RITM comments to SCTASK work notes
task.work_notes = 'RITM Comments: ' + current.comments.getJournalEntry(1);
task.update();
}
}
})(current, previous);
Also check the activity stream in sctask and verify if worknotes field is checked or not
Mark my answer correct and helpful if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 11:06 PM
I don't see any error in the code. Can you give us the activity stream screen shot for sctask? Did you check if the login user has write access to work_notes field in sctask?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2025 11:27 PM
I think it should work as soon as you make it a before BR. But also check the activity stream, because you are only showing the 'work notes' field and that will never be filled by automation.