Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

regarding email notification

shreya_3009
ServiceNow Employee

i should an approval table in an email notification, so i written a email script and added to email notification.When i am checking in preview notification the approval table is visible but after submitting the request and when i check in system logs>email>preview email i am unable to see that table.
Could you pls help me out.

 

7 REPLIES 7

KrishnaMohan
Tera Sage

@shreya_3009  could you share script.

(function runMailScript(current, template, email, email_action, event) {

var approvalGr = new GlideRecord('sysapproval_approver');
approvalGr.addQuery('sysapproval', current.sys_id);
approvalGr.orderBy('sys_created_on');
approvalGr.query();
if (approvalGr.hasNext()) {
template.print("Approval History:<br/>");
template.print("<table border='1' cellpadding='15' text-align='center' style='border-spacing: 0 !important;'>");
template.print("<tr><th>Approver</th><th>Status</th><th>Date of Approval</th></tr>");
}
while (approvalGr.next()) {
template.print("<tr>");
template.print("<td>");
template.print('<a href="' + gs.getProperty('glide.servlet.uri') +
'sn_lg_ops_RedirectionPageForLCCEmailNotif.do?sys_id=' + approvalGr.sys_id + '">' +
approvalGr.approver.getDisplayValue() + '</a>');
template.print("</td>");

template.print("<td>");
template.print(approvalGr.state.getDisplayValue());
template.print("</td>");
template.print("<td>");
template.print(approvalGr.sys_updated_on.getDisplayValue());
template.print("</td>");
template.print("</tr>");
}
template.print("</table>");
}

)(current, template, email, email_action, event);
pls consider this as urgency and help if possible.thankyou

@shreya_3009  

 

var approvalGr = new GlideRecord('sysapproval_approver');
I believe there is no such field called sysapproval in sysapproval_approver table in below line 
approvalGr.addQuery('sysapproval', current.sys_id);  
 
replace with sys_id and try to trigger
approvalGr.addQuery('sys_id', current.sys_id);  

If this helped to answer your query, please mark it helpful & accept the solution.
Thanks!
Krishnamohan

@shreya_3009 

Script looks fine.

sysapproval is an OOTB field on that table.

Notification is on which table?

did you add gs.info() to verify what came in logs?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader