How can we get rejected comments in notifications using mail script from Approval table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 11:42 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2019 01:56 AM
Hi Raj,
Please use the script given below and give it a try:
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('state','rejected');
gr.addQuery('sysapproval',current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.comments.getJournalEntry(1));
}
Hope this helps. Please mark the answer Correct/Helpful based on the impact.
Regards,
Amlan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2019 02:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2019 02:20 AM
Hi Raj,
I can see that you are trying the code in the background script. Please use the SysID of the record against which you are trying to get the rejection comments. But when you will be using the script in the mail script please use current.sys_id.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('state','rejected');
gr.addQuery('sysapproval','0f20c9f94f5d3300c1012f9ca310c7f0'); //Replace the SysID of your record here for Background Script validation
gr.query();
while(gr.next()) {
template.print(gr.comments.getJournalEntry(1));
}
Hope this helps. Please mark the answer Correct/Helpful based on the impact.
Regards,
Amlan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2019 02:38 AM
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sys_id','07c01bd5db15bf00242d68d35b961939');
gr.query();
while(gr.next()) {
gs.print(gr.comments.getJournalEntry(1));
}
O/p:-Working fine
But the below one is not woeking means null only we are getting in notifications.
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sys_id',current.sys_id); (or) gr.addQuery('document_id',current.sys_id); (or)gr.addQuery('sysapproval',current.sys_id);
gr.query();
while(gr.next()) {
gs.template(gr.comments.getJournalEntry(1));
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2019 02:47 AM
Hi Raj,
In the email script please use the below script:
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('state','rejected'); //Assuming you are looking for rejection comment.
gr.addQuery('sysapproval',current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.comments.getJournalEntry(1));
}
Hope this helps. Please mark the answer Correct/Helpful based on the impact.
Regards,
Amlan