The CreatorCon Call for Content is officially open! Get started here.

Mail script to get Approval Comments

dagarson
Tera Guru

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 

find_real_file.png

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.

4 REPLIES 4

Community Alums
Not applicable

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);

}

Ankur Swami
Tera Guru

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}.

I am running this on the change of the wf state which updates when the article is approved the notification fires but is blank I am just calling the mail script

find_real_file.png

Sterling2
Kilo Explorer

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.