Mail script to get Approval Comments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-30-2021 10:27 AM
Hello Im trying to create a mail script that I can use on the approval of a knowledge article that will contain the comments added to the approval record but it doesn't seem to work.
this is what I am trying to grab
This is my script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var com = new GlideRecord('sysapproval_approver');
com.addQuery('sysapproval', current.sys_id);
com.query();
while (com.next()) {
template.print("Comments: " + com.comments.getJournalEntry(1));
}
})(current, template, email, email_action, event);
Any assistance would be apprieciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-30-2021 11:04 AM
can you try below
var com = new GlideRecord('sysapproval_approver');
com.addQuery('sysapproval', current.sys_id);
com.query();
if(com.next()) {
var journal = com.comments.getJournalEntry(-1);
var comments = journal.split("\n\n");
var comment = comments[0].split("\n")[1];
template.print("Comments: " + comment);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-30-2021 11:10 AM
Hi ,
I am able to execute your email script and it is working fine. Make sure you are calling this script in your notification correctly.
The tag to adding email script in notification is : ${mail_script:name_of_your_email_script}.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-30-2021 11:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-30-2021 11:17 AM
This post is not intended to be a full explanation of the approval email notification process but I think a short explanation is helpful in understanding the problem we faced PayGOnline. When an approval record is put into a requested state.