- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 07:55 AM
Hi All,
Can we copy worknotes in the task when it is updated in RITM of a catalog.
I have tried the below Business rule, looks like after and async is not working and when trying with Before, I am getting an error "Before Business Rules should not modify records on other tables".
I have kept the filter to run this BR on one specific catalog only with update/insert option.
(function executeRule(current, previous /*null when new*/ ) {
//if (current.cat_item.sys_id == '9690844b1b0e7f406380777b1d4bcb28') {
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', current.sys_id);
tasks.query();
while (tasks.next()) {
gs.info('update worknotes');
tasks.work_notes = current.work_notes;
tasks.update();
}
// }
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:01 AM
@shivani39 Use the following BR script to copy work notes from RITM to SC Task.
(function executeRule(current, previous /*null when new*/ ) {
//if (current.cat_item.sys_id == '9690844b1b0e7f406380777b1d4bcb28') {
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', current.sys_id);
tasks.query();
while (tasks.next()) {
tasks.work_notes = current.work_notes.getJournalEntry(1);
tasks.update();
}
// }
})(current, previous);
Always use work_notes.getJournalEntry(1); to get the latest work notes.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:01 AM
@shivani39 Use the following BR script to copy work notes from RITM to SC Task.
(function executeRule(current, previous /*null when new*/ ) {
//if (current.cat_item.sys_id == '9690844b1b0e7f406380777b1d4bcb28') {
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', current.sys_id);
tasks.query();
while (tasks.next()) {
tasks.work_notes = current.work_notes.getJournalEntry(1);
tasks.update();
}
// }
})(current, previous);
Always use work_notes.getJournalEntry(1); to get the latest work notes.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 06:07 AM
This has failed the testing, looks like the same worknote is appearing with task number multiple times. Meaning, if we have 3 task created for one RITM, the same worknotes from RITM is appearing along with 3 task number on the worknotes of the task. Please refer below image. We just want one worknote to appear. Could you please help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 08:37 AM
@shivani39 Looks like you haven't put a condition on the business rule on RITM. Please update the business rule condition as follows.
Here in item choose the catalog item for your RITM where you would like to copy the worknotes
Also, make sure to keep work notes change condition.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 03:19 AM - edited 04-28-2023 03:20 AM
Hello Sandeep, these conditions I have already kept. The thing is "Before" BR isn't working and throwing Best practice error(before BR cannot be used in other table). So I have used "After" BR, which is copying the actual worknotes in the task, but also copying the worknotes of 2nd task. Please refer image.