Copy work_notes from closed task to new task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello.
I have a catalog item that generates 2 tasks. Catalog item is submitted and task 1 generates. When task 1 closes, then task 2 generates.
What I would like to do is when task 1 closes, copy ALL work notes from task 1, and add them to task 2.
I only want this functionality on this catalog item as well.
I created an after update business rule on the sc_task table when state changes to Closed Complete.
And the check on the catalog item is in the script, but not getting it to work. Any reccomendations?
(function executeRule(current, previous /*null when async*/) {
// Ensure task has a RITM
if (!current.request_item)
return;
// Load RITM
var ritm = new GlideRecord('sc_req_item');
if (!ritm.get(current.request_item))
return;
//Only for THIS catalog item
if (ritm.cat_item != 'dbc731321b9fc010a4f4fee58d4bcbdf')
return;
// Get ALL work notes from closing task
var allNotes = current.work_notes.getJournalEntry(-1);
// ALL entries [1](https://www.servicenow.com/community/developer-forum/basic-understanding-of-getjournalentry-1/m-p/1355790)
if (!allNotes)
return;
// Find next active task under the same RITM
var nextTask = new GlideRecord('sc_task');
nextTask.addQuery('request_item', current.request_item);
nextTask.addQuery('sys_id', '!=', current.sys_id);
nextTask.addActiveQuery();
nextTask.orderBy('sys_created_on');
nextTask.setLimit(1);
nextTask.query();
if (nextTask.next()) {
nextTask.work_notes =
"Copied from previous task " + current.number + ":\n\n" + allNotes;
nextTask.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5m ago
One reason could be that by the time this business rule is getting executed, the 2nd task may not have created. could be few seconds time delay.
You can try to write similar business rule upon creation of second task instead.

