
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2014 02:53 PM
I have a request to make it so that the approvers comments they put in the comments section. How to I go about placing the approver comments into the task?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2016 04:15 AM
This is what our Approval Events (Task) business rule look like. It was modified by the company that helped us setup ServiceNow. How ever even if you want to use a group for approve you still have to use the approval user task in the workflow as that one works for both individuals and groups. That is the only time that approval comments show up.
function checkRequest() {
var task = current.sysapproval.sys_class_name;
return (task == 'sc_request');
}function checkSCTask() {
var task = current.sysapproval.sys_class_name;
return (task == 'sc_task');
}var isRequest = checkRequest();
var isSCTask = checkSCTask();if (current.state.changes() && current.state=='cancelled') {
var event = "approval.cancelled";
if (isRequest)
event = "request.approval.cancelled";
else if (isSCTask)
event = "sc_task.approval.cancelled";
gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
}if (current.state.changes() && current.state=='requested') {
var event = "approval.inserted";
if (isRequest)
event = "request.approval.inserted";
else if (isSCTask)
event = "sc_task.approval.inserted";
gs.eventQueue(event, current, gs.getUserID(), gs.getUserName());
updateTask(current, current.approver.getDisplayValue() + " requested to approve task");
}if (current.state.changes() && current.state=='rejected') {
var event = "approval.rejected";
if (isRequest)
event = "request.approval.rejected";
else if (isSCTask)
event = "sc_task.approval.rejected";
gs.eventQueue(event, current, current.state, previous.state);
updateTask(current, gs.getUserDisplayName()+ " rejected the task.", current.comments.getJournalEntry(1));
notifyMyFriends(current);
}if (current.state.changes() && current.state=='approved') {
updateTask(current, gs.getUserDisplayName() + " approved the task.", current.comments.getJournalEntry(1));
}function notifyMyFriends(me) {
var friends = new GlideRecord('sysapproval_approver');
friends.addQuery('sysapproval', me.sysapproval);
friends.query();
while(friends.next()) {
if (friends.approver.toString() != me.approver.toString()) {
gs.eventQueue("approval.rejected.by.other", me, friends.approver);
}
}
}function updateTask(me, journal, comments) {
// if this is for a group approval, don't log this user action since the Group Approval Activity will handle the logging
// if (!current.group.nil())
// return;
// only log the user approval activity for workflows when specifically turned on
// otherwise, we spam the approval history log when it is almost never desired to track via the approval history journal field
var isWorkflow = !current.wf_activity.nil();
if (isWorkflow && (gs.getProperty("glide.workflow.user_approval_history") != "true"))
return;
if (comments)
journal += " Comments: " + comments;
var task = new GlideRecord('task');
if (task.get(me.sysapproval)) {
if (isWorkflow)
task.setWorkflow(false);
task.approval_history.setJournalEntry(journal);
task.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 06:09 PM
How can I achieve same from java code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2019 08:58 AM
I know this is an old post but just want to say it's still relevant and super helpful even 5 years later!! Thanks for this Wendy.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2019 10:33 AM
This worked like a dream, but I needed a little bit more info to meet my needs. I added a little something to this code. Due to the fact that our approvals, on the form I am working on, include a full approval and several partial approvals and I am unable to get breakdowns accordingly, I included a reference to the Workflow Activity, so I could differentiate. This just means that you need to provide clear and concise names for your workflow activities.
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 + " for " + apv.wf_activity.name + "\n" + apv.comments.getJournalEntry(-1); // add approver name here
}
This updated code generates a comment like this...
Approval Comments: from Joe Schmoe for Removable Media Approval
2019-07-23 09:18:44 - Joe Schmoe (Comments)
Removable Drive Access is denied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2014 12:52 PM
Like I said earlier on this we have ours going usually to the Description area if an approver makes notes to it. Sometimes to the Work Notes it depends on what I am doing. Here is how it looks when you have it going to the description. Most of our stuff is role based so approvers alot of the time puts in comments that our Security Admins need to be aware of. You could easily set up anywhere you want those to go.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2016 06:01 AM
I ended up adding approval history to my notes tab and making all approvals user approvals even if it sends it to a group because they were the only ones that write the comments to the approval history