- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 01:16 PM
Can anyone provide some insight on the proper script for the Business Rule that will allow Additional Comments created on the Request to automatically copy to the RITM? I tried using the following with no luck.
Create an after business rule on sc_request table
-When: after insert and update
-Conditions: Additional comments changes
-Script:
var gr= new GlideRecord("sc_req_item");
gr.get(current.getValue("request_item"));
gr.comments=current.comments.getJournalEntry(1);
gr.update();
Thanks,
AJ
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 01:26 PM
Hello
var gr = new GlideRecord('sc_req_item'); gr.addQuery('request',current.sys_id);
gr.query(); while(gr.next())
{
gr.comments = current.comments;
gr.work_notes = current.work_notes;
gr.update();
}
Please mark answer correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 06:16 AM
I don't see where Additional comments has been updated. I see an e-mail attached to the current record, but I see no Additional comments that have been generated from it. Maybe it is off-screen-shot, but not in-screen-shot. That is just a mail, not an Additional comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 04:04 AM
Hi,
try this
I consider you are saving the REQ once comments are changed and not using post button to submit comments
(function executeRule (previous, current) {
var comment = current.comments.getJournalEntry(1);
var gr = new GlideRecord("sc_req_item");
gr.addQuery('request', current.getUniqueValue());
gr.query();
if(gr.next()) {
gr.comments = comment;
gr.update();
}
})(previous, current);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 04:21 AM
Hi Ankur,
Your script doesn't work when the requester replies via email but it does when the requester replies via the portal. This is probably the case with Saurav's and Janos' scripts. However, copying the comments from Req to Ritm when a requester replies via email is what I need help with. Sorry for leaving that out. I didn't think about that scenario since, right now, all of our users communicate via email.
Any ideas on how to resolve this for email replies?
- AJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 04:29 AM
Hi,
Did you verify the BR runs when comments are updated via inbound?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader