- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 03:22 AM
Hi All
In ritm form is some one is approved or rejected the approval then the same message has to be updated in work notes as well, How we can achieve this?
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 06:29 AM
No No. Please see my updated comment . I am posting it again with details which you need to try:
BR Details:
Table name: sysapproval_approver
When: After Update
Condition: Comments Changes
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.sysapproval);
gr.query();
if(gr.next()){
gr.work_notes = current.comments.getJournalEntry(1);
gr.update();
}
})(current, previous);
BR:
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 07:03 AM
Since you want the comments to be moved only during rejection; you add this condition in your after update BR
current.source_table == 'sc_req_item' && current.state == 'rejected' && current.comments.changes()
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
02-10-2022 04:23 AM
Hi,
Write a Before Update Business Rule on Approval table and use the script below:
Table: sysapproval_approver
Before Update
Condition: Comments Changes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.sysapproval);
gr.query();
if(gr.next()){
gr.work_notes = current.comments;
}
})(current, previous);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 04:31 AM
Below code is tested. Use this ins an After Update BR:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id',current.document_id);
gr.query();
if(gr.next()){
gr.work_notes = current.comments.getJournalEntry(1);
gr.update();
}
})(current, previous);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 04:33 AM
Attching the screenshot of the BR as well and Result:
Code to be used:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.sysapproval);
gr.query();
if(gr.next()){
gr.work_notes = current.comments.getJournalEntry(1);
gr.update();
}
})(current, previous);
BR:
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 04:34 AM
Let me know if you are facing an issue. Since Comments is a Journal field you need to use "getJournalEntry(1)" to get the last update comments and copy it to the RITM work notes.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke