- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 04:07 AM
Hi,
can you help me how to copy Approval comments into RITM, REQ, when RITM was REJECTED.
Not Working
here Approvals comments copying to RITM, but Not copied into REQ.
approvalcomments();
function approvalcomments()
{
var grr = new GlideRecord('sc_req_item');
grr.get(current.sysapproval);
grr.comments = current.comments;
grr.update();
var gr = new GlideRecord('sc_request');
gr.get(gr.request);
if(gr.next())
{
gr.comments = current.comments+" " +gr.number;
gr.update();
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 05:20 AM
Working example from my PDI (= tested). Working for Approvals on RITM.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 04:15 AM
Hi there,
Hard to say exactly for your situation, I don't know how your approval is setup, custom field, etc..
Though an approach could be:
onBefore Business Rule, Update checked, Condition (or thru condition builder) State changes to Rejected.
The scripted:
Example for only the RITM!
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_req_item');
if(gr.get('sysapproval')) {
gr.comments = "Comment copied from approval record:\n\n" + current.comments;
gr.update();
}
})(current, previous);
I personally don't like the onBefore + in the script an update on a different record. Though, I think because of the comment type field on your approval, you will need to do onBefore.
Add a gs.info message to the Business Rule, with which you can verify if your Business Rule got triggered. Before moving to production, remove the gs.info message.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 04:19 AM
here Approvals comments copying to RITM, but Not copied into REQ.
approvalcomments();
function approvalcomments()
{
var grr = new GlideRecord('sc_req_item');
grr.get(current.sysapproval);
grr.comments = current.comments;
grr.update();
var gr = new GlideRecord('sc_request');
gr.get(gr.request);
if(gr.next())
{
gr.comments = current.comments+" " +gr.number;
gr.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 05:11 AM
Looking at your script, that's correct:
gr.get(gr.request); is nothing yet. So you are not getting a sc_request record.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 05:20 AM
Working example from my PDI (= tested). Working for Approvals on RITM.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2019 05:45 AM
in case if WE have REQ level Approvals presented on REQ, then is it correct???
reqapprovalcomments();
function reqapprovalcomments()
{
var gr = new GlideRecord('sc_request'); // if REQ had approvals
gr.get(current.sysapproval);
gr.comments = current.comments;
gr.update();
var ghh=new GlideRecord('sc_req_item');
ghh.get('request',gr.sys_id);
ghh.query();
while(ghh.next())
{
//gs.addInfoMessage("RITM numbers is"+ghh.number);//
ghh.comments=current.comments;
ghh.update();
}
}