- 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-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-24-2022 02:14 PM
Thanks Saurav, but that didn't work. I'm not sure if your script was for the Additional Comments for the RITM, but I need from the Additional Comments on the Request to copy to the Additional Comments on the RITM.
Thanks,
AJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 05:31 PM
Saurav's strategy should be OK, just modify it to use your method to get the last comment. In an after Business Rule the comment is empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 05:32 PM
E.g:
(function executeRule (previous, current) {
var comment = current.comments.getJournalEntry(1);
var gr = new GlideRecord("sc_req_item");
gr.addQuery('request', current.getUniqueValue());
gr._query();
while (gr._next()) {
gr.comments = comment;
gr.update();
}
})(previous, current);