Add additional comments to RITM and Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2020 06:44 AM
Will this script work to copy additional comments from RITM to Task and Task to RITM whichever one is updated with additional comments?
(function executeRule(current, previous /*null when async*/)
{
var com = current.comments;
var v_gRITM = new GlideRecord('sc_req_item');
v_gRITM.addQuery('sys_id', current.request_item);
v_gRITM.query();
if (v_gRITM.next())
{
v_gRITM.comments= current.comments;
v_gRITM.update();
}
})(current, previous);
(function executeRule(current, previous /*null when async*/) {
updateTasks();
function updateTasks() {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.query();
while (sctask.next()) {
sctask.work_notes = 'Additonal Comment from RITM' + current.comments;
sctask.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2020 06:51 AM
This is the right idea, but you have to check if the comment already exists on the target record. If it doesn't exist, post it. Otherwise you end up looping and posting comments back and forth indefinitely.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2020 07:11 AM
Yea we have end users that usually updates the RITM and the tech's would have to drill into the RITM to see the comments. They wanted to where it shows up in the task view .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2020 08:40 AM
I posted in additional comments under RITM and that didn't get captured on the task.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2020 08:48 AM
Hi John,
You can try below After Insert/Update business rule that runs on RITM table when Comments | changes
(function executeRule(current, previous /*null when async*/ ) {
var com = "RITM Comments for " + current.number + " : " + current.comments.getJournalEntry(-1);
if(com.indexOf('RITM Comments')>-1 && com.indexOf('Catalog Task comments')==-1)
{
var ritmis = new GlideRecord('sc_task');
ritmis.addQuery('request_item', current.sys_id);
ritmis.query();
if (ritmis.next()) {
ritmis.comments= "RITM Comments for " + current.number + " : " + current.comments;
ritmis.update();
}
}
})(current, previous);
Then another After Insert/Update business rule that runs on Catalog Task table when Comments | changes
as below
(function executeRule(current, previous /*null when async*/ ) {
var com = "Catalog Task Comments for " + current.number + " : " + current.comments.getJournalEntry(-1);
if(com.indexOf('RITM Comments')==-1 && com.indexOf('Catalog Task comments')>-1)
{
var catis= new GlideRecord('sc_req_item');
catis.addQuery('sys_id', current.request_item);
catis.query();
if (catis.next()) {
catis.comments= "Catalog Task Comments for " + current.number + " : " + current.comments;
catis.update();
}
}
})(current, previous);
To make it understand what we do is as below.
1. When comments are copied from RITM to Catalog task we add static text 'RITM comments'. Once done we check it in IF statement for the keyword. So, if keyword has 'RITM comments' & does not have 'Catalog Task' as keyword. Only then we will copy it to Catalog Task's comments field.
2. So, now when Catalog Task business rule that copies comments to RITM is processed it will check for keyword that has 'Catalog Task comments' & does not have 'RITM comments' thus ensuring the comments are not copied back & forth thus avoiding duplication.