
- 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
02-07-2014 02:33 AM
Hi Bricast,
It is not possible to place the approvers comments in task, because the relation ship between Task --> approval table is m:1. You can place the approver comments in a related list on task or write a business rule to copy the approver comments and update the journal field on task or create a new field for the same.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2014 08:38 AM
could you provide more details on how to go about this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2014 07:40 AM
Can anybody give me more info on how to do any of this. I am really new with servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2014 08:41 AM
Hi,
I think the easiest way for you will be "to write a business rule to copy the approver comments and update the journal field on task." (as chandz098 said)
If you want an example, please take a look on the OOB "Update Child Incidents" business rule.
If you want to propose a code and ask for a review feel free
For doing this feature, I think the "system admin" course is necessary (or a good knowledge of coding + some hours on the wiki) and if you're not confident, the "scripting course" will help you a lot.
An hint: If you have more than 5 lines of code (excluding "spaces" or "brackets"), ask yourself the question "Is it ok?", if you have more than 10, you'll highly probably on a wrong way to perform it.
Basically, I say to my new coworkers: "Where is the source of the information, where is the target, do you need to transform the information between the source and the target"
Regards,