Add Rejection Comments to Change email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 07:33 AM
I have a need to add the comments to the reply email when a Change or RITM is rejected.
I know the field I want is Comments in the sysapproval_approver table but unable to add it to the email.
- Labels:
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 08:06 AM
Are you using "legacy" Email Notificaitons to trigger the email or "modern" Flow?
Either way you need to write a mailscript (or script) to glide to the approval table, for the comment - how depends on which method you are using.
Also, comments are a journal field, so you need to determine what content of comment journal field on the sysapprover table, you want to send via email (most recent comment, all comments)...
For instance, if you use "traditional" Email Notifications and mailscripts, and the notification is triggered from the change table, your mailscript could look like this (pseudo code, not tested - just for demo purposes):
var chgNum = current.triggerNumber; //the "current" is the email record, but it should have a "triggering record" value that you can use here
var input; //used to parse the journal entries
var addSpaces = "(Additional details)".length; //used to parse journal entries
var startPos = input.indexOf("(Additional details)") + addSpaces; //used to parse journal entries
var rejectComment; //this is the comment you want from the approver table
var approve = new GlideRecord('sysapproval_approver');
approve.addQuery('sysapproval', chgNum); //assuming this is the only approval for that change
approve.query();
while (approve.next()) {
input = approve.comments.getJournalEntry(1);
rejectComment = input.substring(startPos);
};
template.print(rejectComment);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2023 09:19 AM
are using the Legacy notifications.