
- 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
07-13-2015 07:52 AM
What's the scenario you are trying to do. You mean one Request has Task 1 - Task 2 and Task 3 and you want to move them to Task 4?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 08:00 AM
Yes, I have Task1 and then an approval. I would like the work notes from Task 1 and the comments from the approval to go to the worknotes of Task 2, which is generated after approval. Your script, above, works great and applied the Approval Comments to the worknotes. I just need to get the notes from Task 1.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 08:40 AM
Your best bet is going to be sending it to the Work Notes on the RITM and then from there sending it to Task 2. Information from Task 1 to Task 2 doesn't work very good unless you have a field you are pulling it somewhere from. If you send it to the Worknotes on the RITM then you could easily pull it into Task 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 09:28 AM
Thanks, Wendy.
How would I go about posting the task worknotes to the RITM notes and then call them back for Task 2? Using a GlideRecord call?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2015 09:43 AM
I would just add it in the Workflow if it was me
//Adds approver comments to Worknotes Area
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
current.work_notes += "\n Approval Comments: from " + apv.approver.name + "\n" + apv.comments.getJournalEntry(-1); // add approver name here
}
Then in your next task where you want the worknotes you could just add task.work_notes = current.work_notes;
Or you could send them to the description of the RITM also so they are not journaled that way and then send them the same way depending if you have anything being sent to the description area at all.