Copying RITM worknotes and comments to TASK are generating duplicate comments on RITM activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-05-2020 01:12 PM
Hi Team,
Could you please help me to remove Task work_notes and comments from RITM Activity.
Here is my business rule
written on Before Update
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query();
while(gr.next())
{
//gr.comments = current.comments;
gr.work_notes = current.work_notes;
gr.comments = current.comments;
gr.update();
}
// Add your code here
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-05-2020 01:25 PM
Do you have a business rule on sc_task table that is copying comments from task to the parent RITM?
It's difficult to tell what is happening in your activity log screenshot, you typed 'test' in work notes of the RITM (from what I assume). And this wrote 'test' on TASK0080746? Then TASK0080746 wrote 'test' back onto the RITM?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-05-2020 01:27 PM
If it is adding duplicate comments, you need to add code that checks if it already exists on that record.
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.query();
while (gr.next()) {
//gr.comments = current.comments;
if(gr.comments.getJournalEntry(1).indexOf(current.comments) == -1 && gr.work_notes.getJournalEntry(1).indexOf(current.work_notes) == -1) {
gr.work_notes = current.work_notes;
gr.comments = current.comments;
gr.update();
}
}
// Add your code here
})(current, previous);
Please mark this as helpful/correct if it answered your question!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-05-2020 04:15 PM
It should be an after update Business rule.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-05-2020 09:09 PM
@Elijah Aromola thanks for the inputs but it is still reflecting in RITM activity.
Business rule is on Before - Update on SC_REQ_ITEM table.
whenever I am updating any comments and worknotes on RITM its copying into the tasks that's is working fine but it is also reflecting multiple times on the RITM's activity due to which multiple notification are getting trigger, which should not happen.
RITM Activity bringing comments and worknotes of task too .