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 01:54 PM
Hi Tim,
The 'Rejected' on the Approval form is from the field 'state'.
So, you need to change the mail script to something like:
chRej.addQuery("sysapproval", current.sys_id);
chRej.addQuery("state", "rejected");
chRej.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 01:57 PM
Mani,
Thanks! I tried that originally, but it doesn't work. The query does not return any results, so the items in the while loop are not executed. Let me check again and see if I am missing something.
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 02:22 PM
Hi Tim,
I see that the OOTB 'change.itil.approver.reject' is on the Approval table.
If thats the case in your implementation then, you need to have the script something like:
chRej.addQuery("sysapproval", current.sysapproval.sys_id);
chRej.addQuery("state", "rejected");
chRej.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2015 02:31 PM
Thanks again!
I just tried what you suggested, and modified from 'current.sys_id' to 'current.sysapproval.sys_id', and now what seems to be happening is a completely random rejection comment, which is part of a hardware request (not a change, as in this case), is sent in the email.
I'll keep trying....
Tim