How to Copy Approval comments into RITM, REQ

chanikya
Tera Guru

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();
}
}

 

1 ACCEPTED SOLUTION

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

---

LinkedIn

find_real_file.png

find_real_file.png

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

13 REPLIES 13

Looks pretty oke. Only one thing: I don't think the ghh.get will work. Change it into ghh.addQuery.

ghh.get('request',gr.sys_id);

into

ghh.addQuery('request',gr.sys_id);

(where gr.sys_id is actually the same as current.sysapproval)

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I used the above solution and it works great. My business rule didn't have a state condition, just copy the contents regardless. The only thing I noticed is that if the approval goes to a group, it will try to copy the comments from each approval record. So if the group has 5 people who could approve, it has 5 additional actions that say comment copied from approval record and only 1 will have comments in it. I know this is old, but is there a way to restrict to only grab contents from the approval record that approved it?

Jyoti8
Kilo Guru

Hi chanikya,

 

These link might help you.

 

https://community.servicenow.com/community?id=community_question&sys_id=3dfc8369db9cdbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=092d43a9db9cdbc01dcaf3231f96...

 

If I have answered your question, please mark my response as correct and/or helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you.

in case if WE have REQ level Approvals presented on REQ, then is it correct???

 

find_real_file.png

 

 

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();
}

}