How can we get rejected comments in notifications using mail script from Approval table

Raj90
Tera Guru

I wrote an email script.

Email script:-  rejected_comments

 var gr = new GlideRecord('sysapproval_approver');
       gr.addQuery('state','rejected'); or)
       gr.addQuery('document_id',current.sys_id);
      gr.query();
while(gr.next()) {
gs.template(gr.comments.getJournalEntry(1));
}

I called the email script in Notifications body like in the below way

 ${mail_script:rejected_comments}

But in notifications, I'm not getting comments.

Thanks

Raj

 

11 REPLIES 11

Prateek kumar
Mega Sage

Change this line to below: gs.template(gr.comments.getJournalEntry(1));

template.print(gr.comments.getJournalEntry(1));

 

 var gr = new GlideRecord('sysapproval_approver');
       gr.addQuery('state','rejected');
       gr.addQuery('document_id',current.sys_id);
      gr.query();
while(gr.next()) { 
gs.template(gr.comments.getJournalEntry(1));
}


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Hi Prateek,

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('state','rejected');
gr.addQuery('document_id',current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.comments.getJournalEntry(1));
}

O/P:-

find_real_file.png

Kotaiah
Kilo Guru

Hi Raj,

 

Why we need to glide 'sysapproval_approver' table. Just with the below code we can achieve the same.

 

if(current.state == 'rejected'){

template.print(current.comments.getJournalEntry(1));

}

 

Regards,

Kotaiah Sadari

Hi Koti,

Not working

find_real_file.png     

 

Thanks