Approval Rejection Notification

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 01:32 PM
A while ago, I requested assistance in this thread:
Change Request Rejected Comments
And was able to successfully get the notification to work. What has been happening, however, is the notification will get send back to the requester stating the change has been rejected, and the 'rejected by' user may not be the correct one. We have three levels of approval for change. For simplicity's sake, let's say:
Joe Smith
Jane Smith
Bob Manager
So, Joe approves, then Jane approves, and Bob rejects. The requester gets the notification email stating 'Your Change has been rejected by Jane Smith', which is incorrect. The change was rejected correctly, and if you look at the change form, everything is fine, just the notification is displaying incorrect info.
Here is the mail script:
<mail_script>
template.print("<span style=\"font-size: 10pt; font-family: Verdana, Arial\">Your Change Request <b>" + current.number + " - " + current.short_description + "</b> has been rejected with the following comments:");
// Select the proper table
var chRej = new GlideRecord("sysapproval_approver");
chRej.addQuery("sysapproval", current.sys_id);
chRej.query();
while (chRej.next()) {
email.setSubject("Your Change Request has been rejected by " + chRej.approver.getDisplayValue());
template.print("\n\n" + chRej.comments.getJournalEntry(1) + "\n");
template.print("</span>");
}
</mail_script>
I asked one of our implementation specialists to take a look and see if there was something wrong with this script. She suggested the issue is that there is nothing in that query that filters on the rejected approval or the last updated by. She suggested I try adding another query that looks for the approval being rejected:
chRej.addQuery("sysapproval", current.sys_id);
chRej.addQuery("approval", "rejected");
chRej.query();
So, I did just that, and the issue is still happening. Any idea as to what I can add/modify to make this work correctly? I'm sure I'm just missing something simple. I am not too sure what else to check. Any ideas would be appreciated!
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 02:44 PM
what table is this script running on?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 02:48 PM
It's running on the change_request table. I was just thinking, maybe I should be running this on the sysapproval_approval table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 02:53 PM
that is the root of your problem you should run it on the sysapproval_approver table in order for current. to have the sysapproval records..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 03:03 PM
Thanks Doug, I will try using the other table.
Tim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 04:28 PM
I now remember why I set this up using the change_request table. In the 'Who will receive' tab, I have the notification being sent to the 'assigned_to' and 'requested_by' users. I cannot select these if I have the 'sysapproval_approver' table selected. I tried searching through all of the available variables in the list, and these don't exist with the approval table selected.
I need this notification to go back to the user who requested the change. Any other ideas?
Cheers,
Tim