Is there any way to get "Approval Comments" to go to a SC Task

Wendy Peterson
Giga Guru

Is there anyway I can get "Approval Comments" to show up in the "SC Task"? So it goes to the support group. Approvers might change a role for someone and they comment there and they are getting missed cause they don't go to the task... TIA

13 REPLIES 13

zachkenyon
ServiceNow Employee
ServiceNow Employee

Yes, for one of our items I copy the approval comments to the Description field in the sc_task with this code in the Advanced Script field on the Catalog Task workflow activity that creates the task. This is for an approval on the Request Item, if you wanted to find an approval attached to the Request, you'd query for current.request.sys_id instead of current.sys_id.


var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.query();

if (apv.next()) {
task.description += "\nApproval Comments:\n" + apv.comments;
}


Hi Zach,


Im hoping you might be able to help me with a query I have on this if possible.


I have 2 levels of approval on the catalogue - the Request and the RITM.


In order to transfer the comments from the Request approval to the Task I use 'apv.addQuery('sysapproval',current.request.sys_id);'


To transfer the comments from the ritm approval to the task I use 'apv.addQuery('sysapproval',current.sys_id);',


However, I want to transfer both together into the Task.


Ive been able to do it by using the below (basically adding the script twice and changing the one line). It adds both sets of comments but seems to transfer one of the comments in twice.


Did you encounter this at any point?



var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.request.sys_id);
apv.addQuery('comments','!=','') // add this to only find approvals that have comments on them
apv.query();


while (apv.next()) { // change if to while so it will go through all approvals with comments
task.comments += "\nApproval Comments: from " + apv.approver.name + "\n" + apv.comments.getJournalEntry(-1); // add approver name here
}


var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.addQuery('comments','!=','') // add this to only find approvals that have comments on them
apv.query();


while (apv.next()) { // change if to while so it will go through all approvals with comments
task.comments += "\nApproval Comments: from " + apv.approver.name + "\n" + apv.comments.getJournalEntry(-1); // add approver name here
}


Wendy Peterson
Giga Guru

I tried that and i see the wording Approval Comments but for some reason it doesn't put the actual comments in there. is there a special ACL that i need to open up. I didn't think so since IT can see the comments. Would it matter cause we have 2 approvals on a RITM - Manager then the Role Owner?

We have our approvals on the RITM also.. not REQ

See screenshot i can see them there but not in the task..


There are 3 approvals on that RITM and the code I pasted was only desgined to deal with one approval. Given that situation, I'd modify it so it will go through all of the approvals, find only those with comments, and add the comments to the task:


var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval',current.sys_id);
apv.addQuery('comments','!=','') // add this to only find approvals that have comments on them
apv.query();

while (apv.next()) { // change if to while so it will go through all approvals with comments
task.description += "\nApproval Comments: from " + apv.approver.name + "\n" + apv.comments; // add approver name here
}