- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 08:11 AM
Hi Team,
I need to copy comments from Approval(sysapproval_approver) to RITM, how to achieve it?
Regards,
Akshata Patil
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 09:02 AM
Hi,
Try this:
//Name: Copy comments from Approval to RITM
//Table: sysapproval_approver
//Advanced: true
//When: Before Update; Additional Comments <changes>
//Condition: current.comments.changes() && current.comments.indexOf('Comment added from:') < 0;
// Note that the condition prevents the note from copying multiple times.
//Script:
(function executeRule(current, previous /*null when async*/) {
if(current.comments.nil()){
return;
}
else {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.document_id);
gr.query();
while(gr.next()){
gr.comments = "Comment added from: " + current.number + " | " +current.request_item.cat_item.name + "\n >>> " +current.comments;
gr.update();
}
}
})(current, previous);
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 08:58 AM
Create business rule on sysapproval_approver table to get the comments and record sys_id using which you can add the comments to sc_req_item table.
Thanks & Regards,
Vasanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 09:02 AM
Hi,
Try this:
//Name: Copy comments from Approval to RITM
//Table: sysapproval_approver
//Advanced: true
//When: Before Update; Additional Comments <changes>
//Condition: current.comments.changes() && current.comments.indexOf('Comment added from:') < 0;
// Note that the condition prevents the note from copying multiple times.
//Script:
(function executeRule(current, previous /*null when async*/) {
if(current.comments.nil()){
return;
}
else {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.document_id);
gr.query();
while(gr.next()){
gr.comments = "Comment added from: " + current.number + " | " +current.request_item.cat_item.name + "\n >>> " +current.comments;
gr.update();
}
}
})(current, previous);
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2022 09:36 AM
Thank you it worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2025 01:06 PM
Hi Dan,
I tried writing this business rule but this does not seem to work. Any suggestions here?
Thanks,
Kushala