notification in table format

Shaik Imran
Tera Contributor

How to create a notification in table format

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

@Shaik Imran 

there are lot of community posts which have the approach

did you try that?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Shaik Imran 

 

https://www.servicenow.com/community/itsm-forum/show-the-content-in-a-table-format-in-notification/m...

https://www.servicenow.com/community/developer-forum/how-to-create-table-in-notification-email-scrip...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Shaik Imran
Tera Contributor

function highlight(text, bgcolor, italic) { var style = 'font-family: Arial, sans-serif; font-size: 14pt;'; if (bgcolor) style += ' background-color:' + bgcolor + ';'; if (italic) style += ' font-style:italic;'; return '<span style="' + style + '">' + text + '</span>'; } // Section headers (bold, 15pt) var headerStyle = 'font-family: Arial, sans-serif; font-size: 15pt; font-weight: bold;'; // Body text (normal, 14pt) var bodyStyle = 'font-family: Arial, sans-serif; font-size: 14pt; font-weight: normal;'; // Link style (blue) var linkStyle = 'color: #2a6496; text-decoration: underline; font-family: Arial, sans-serif; font-size: 14pt; font-weight: normal;'; // Red footer, 12pt var footerStyle = 'color: #FF0000; font-family: Arial, sans-serif; font-size: 12pt; font-weight: normal;'; // Incident Roles template.print('<span style="' + headerStyle + '">Incident Manager:</span> ' + highlight('No Change', '#00FF00', false) + '<br>'); template.print('<span style="' + headerStyle + '">Communication Specialists:</span> ' + highlight('No Change', '#00FF00', false) + '<br>'); template.print('<span style="' + headerStyle + '">Technology Owner:</span> ' + highlight('No Change', '#00FF00', false) + '<br><br>'); // Questions Section template.print('<span style="' + headerStyle + '">Questions about this Incident?</span> '); template.print('<span style="' + bodyStyle + '">Contact the Critical Incident Communications team at </span>'); template.print('<a href="tel:216-471-4888" style="' + linkStyle + '">216-471-4888</a>'); template.print('<span style="' + bodyStyle + '"> or reply to this email. </span>'); template.print(highlight('(Verbiage change)', '#FFFF00', true) + '<br><br>'); // Icon (replace src if using different image) template.print('<img src="https://img.icons8.com/ios-filled/50/000000/communication.png" style="width:34px;height:34px;vertical-align:middle;"><br><br>'); // Feedback Section template.print('<span style="' + headerStyle + '">Feedback?</span> '); template.print('<span style="' + bodyStyle + '">We’re always looking to continuously improve our communications. Click </span>'); template.print('<a href="YOUR_FEEDBACK_LINK" style="' + linkStyle + '">here</a>'); template.print('<span style="' + bodyStyle + '"> to provide feedback via our short survey. </span>'); template.print(highlight('Verbiage change with static link to survey and new logo', '#FFFF00', true) + '<br><br>'); // Footer/Disclaimer template.print('<span style="' + footerStyle + '">KeyBank Internal Only: Do not forward externally. </span>'); template.print(highlight('(New Verbiage)', '#FFFF00', true));

function highlight(text, bgcolor, italic) {
  var style = 'font-family: Arial, sans-serif; font-size: 14pt;';
  if (bgcolor) style += ' background-color:' + bgcolor + ';';
  if (italic) style += ' font-style:italic;';
  return '<span style="' + style + '">' + text + '</span>';
}

// Section headers (bold, 15pt)
var headerStyle = 'font-family: Arial, sans-serif; font-size: 15pt; font-weight: bold;';
// Body text (normal, 14pt)
var bodyStyle = 'font-family: Arial, sans-serif; font-size: 14pt; font-weight: normal;';
// Link style (blue)
var linkStyle = 'color: #2a6496; text-decoration: underline; font-family: Arial, sans-serif; font-size: 14pt; font-weight: normal;';
// Red footer, 12pt
var footerStyle = 'color: #FF0000; font-family: Arial, sans-serif; font-size: 12pt; font-weight: normal;';

// Incident Roles
template.print('<span style="' + headerStyle + '">Incident Manager:</span> ' + highlight('No Change', '#00FF00', false) + '<br>');
template.print('<span style="' + headerStyle + '">Communication Specialists:</span> ' + highlight('No Change', '#00FF00', false) + '<br>');
template.print('<span style="' + headerStyle + '">Technology Owner:</span> ' + highlight('No Change', '#00FF00', false) + '<br><br>');

// Questions Section
template.print('<span style="' + headerStyle + '">Questions about this Incident?</span> ');
template.print('<span style="' + bodyStyle + '">Contact the Critical Incident Communications team at </span>');
template.print('<a href="tel:216-471-4888" style="' + linkStyle + '">216-471-4888</a>');
template.print('<span style="' + bodyStyle + '"> or reply to this email. </span>');
template.print(highlight('(Verbiage change)', '#FFFF00', true) + '<br><br>');

// Icon (replace src if using different image)
template.print('<img src="https://img.icons8.com/ios-filled/50/000000/communication.png" style="width:34px;height:34px;vertical-align:middle;"><br><br>');

// Feedback Section
template.print('<span style="' + headerStyle + '">Feedback?</span> ');
template.print('<span style="' + bodyStyle + '">We’re always looking to continuously improve our communications. Click </span>');
template.print('<a href="YOUR_FEEDBACK_LINK" style="' + linkStyle + '">here</a>');
template.print('<span style="' + bodyStyle + '"> to provide feedback via our short survey. </span>');
template.print(highlight('Verbiage change with static link to survey and new logo', '#FFFF00', true) + '<br><br>');

// Footer/Disclaimer
template.print('<span style="' + footerStyle + '">KeyBank Internal Only: Do not forward externally. </span>');
template.print(highlight('(New Verbiage)', '#FFFF00', true));

Shaik Imran
Tera Contributor
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
    if (current.u_email_type != 'pis') {
        template.print('<br/><p><strong>' + gs.getMessage('Incident Manager: ') + current.u_recovery_manager);        
        if (!current.u_communication_specialist.nil()) {
            template.print('<strong>' + gs.getMessage('Communication Specialist: ') + current.u_communication_specialist);
        }

        if (current.u_technology_owner != "") {
            template.print('<strong>' + gs.getMessage('Technology Owner: ') + current.u_technology_owner);
        }

    }   

})(current, template, email, email_action, event);



<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid rgb(136, 136, 140); height: 207.9px;">
<tbody><!-- Table Title -->
<tr style="height: 23.1px;">
<td style="background-color: rgb(136, 136, 140); color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid rgb(136, 136, 140); height: 23.1px;" colspan="2"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">Critical Incident Communication</span></td>
</tr>
<!-- Priority Banner -->
<tr>
<td style="background-color: ${mail_script:cic_priority_color}; color: ${mail_script:cic_priority_textcolor}; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;" colspan="2"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">Priority ${mail_script:cic_priority}</span></td>
</tr>
<!-- Incident hyperlink (WHITE row, no shading) -->
<tr style="height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); padding: 4px; height: 15.4px;" colspan="2"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">${URI_REF}</span></td>
</tr>
<!-- Priority (gray row) -->
<tr style="background-color: rgb(242, 242, 242); height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Priority:</span> ${priority}</span></td>
</tr>
<!-- Start (white row) -->
<tr style="height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Start:</span> ${u_outage_start}</span></td>
</tr>
<!-- Resolved (gray row) -->
<tr style="background-color: rgb(242, 242, 242); height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Resolved:</span> ${u_outage_end}</span></td>
</tr>
<!-- Duration (white row) -->
<tr style="height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Duration:</span> ${mail_script:cic_duration}</span></td>
</tr>
<!-- Systems Impacted (gray row) -->
<tr style="background-color: rgb(242, 242, 242); height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Systems Impacted:</span> ${mail_script:cic_getAffectedProducts}</span></td>
</tr>
<!-- Description (white row) -->
<tr style="height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Description:</span> ${u_cic_description}</span></td>
</tr>
<!-- Impact to Clients (gray, full width) -->
<tr style="background-color: rgb(242, 242, 242); height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Impact to our Clients:</span> ${u_external_impact}</span></td>
</tr>
<!-- Impact to Employees (white, full width) -->
<tr style="height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Impact to our Employees:</span> ${u_internal_impact}</span></td>
</tr>
<!-- Cause (gray, full width) -->
<tr style="background-color: rgb(242, 242, 242); height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Cause:</span> ${u_probable_cause}</span></td>
</tr>
<!-- Resolution Activities (white, full width) -->
<tr style="height: 15.4px;">
<td style="border: 1px solid rgb(136, 136, 140); height: 15.4px;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Resolution Activities:</span> ${u_resolution_activities}</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span data-teams="true">${mail_script:cic_footer}</span></span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span data-teams="true">${mail_script:im_cic_reply_to}</span> </span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span data-teams="true">${mail_script:im_cic_sub_restored}</span> </span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Questions about this Incident? </span>Contact the Critical Incident Communications team at <a href="tel:+12164714888">216-471-4888</a> or reply to this email.</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><img src="/sys_attachment.do?sys_id=ff4617bc874d7a10e30898a73cbb35af" width="41" height="33" align="left" hspace="12">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-weight: bold;">Feedback?&nbsp;</span>We&rsquo;re always looking to continuously improve our communications. Click&nbsp;<a title="https://kbna.sharepoint.com/sites/Incidentteam/_layouts/15/listforms.aspx?cid=YWE5ZDVhOGYtZWIxMy00MTFkLTllNDctMjFjM2JlYTg3Nzdi&amp;ct=1761918126423&amp;or=Teams-HL&amp;nav=NmFkZTdlMmUtYTRmZS00ZjMwLWJiNTQtZDc0NzllYTg0M2Y3&amp;LOF=1&amp;xsdata=MDV8MDJ8fDRjM2E3NjgwYWRjNTQ1MzY0OTBlMDhkZTE4ODM1YTYwfDhjOGFhZGU1MWM0MTQxZGU4ZWEzMTg5ZWUyYjQ4MWIzfDB8MHw2Mzg5NzUxNDk1NjkyNDY5NDl8VW5rbm93bnxWR1ZoYlhOVFpXTjFjbWwwZVZObGNuWnBZMlY4ZXlKRFFTSTZJbFJsWVcxelgwRlVVRk5sY25acFkyVmZVMUJQVEU5R0lpd2lWaUk2SWpBdU1DNHdNREF3SWl3aVVDSTZJbGRwYmpNeUlpd2lRVTRpT2lKUGRHaGxjaUlzSWxkVUlqb3hNWDA9fDF8TDJOb1lYUnpMekU1T2pjek9Ua3dZakEwTFRKaFpEa3ROR1prTmkwNE0yRmlMVFZrWkdZM09UTmhabVF4WVY5aU1XRXdPRFE1TlMwMVpqUXlMVFEyWW1JdE9UZGxNaTB6TjJVell6VXpOVFZrT1RkQWRXNXhMbWRpYkM1emNHRmpaWE12YldWemMyRm5aWE12TVRjMk1Ua3hPREUxTkRrMU9BPT18NTYxNWY3NmZiMDNmNDRlY2YwZWEwOGRlMTg4MzVhNWZ8N2Y3YTAzYmE3YjJmNDQ1YWFiM2Q1ZGZjYzdhNThhOTk%3D&amp;sdata=ZHMwM1h4QVRGNWpRallHemtlcU5MTXlsdW1xVmg3NUJNVllHRUorMitQbz0%3D&amp;ovuser=8c8aade5-1c41-41de-8ea3-189ee2b481b3%2Cjill_mortensen%40keybank.com" href="https://kbna.sharepoint.com/sites/Incidentteam/_layouts/15/listforms.aspx?cid=YWE5ZDVhOGYtZWIxMy00MTFkLTllNDctMjFjM2JlYTg3Nzdi&amp;ct=1761918126423&amp;or=Teams-HL&amp;nav=NmFkZTdlMmUtYTRmZS00ZjMwLWJiNTQtZDc0NzllYTg0M2Y3&amp;LOF=1&amp;xsdata=MDV8MDJ8fDRjM2E3NjgwYWRjNTQ1MzY0OTBlMDhkZTE4ODM1YTYwfDhjOGFhZGU1MWM0MTQxZGU4ZWEzMTg5ZWUyYjQ4MWIzfDB8MHw2Mzg5NzUxNDk1NjkyNDY5NDl8VW5rbm93bnxWR1ZoYlhOVFpXTjFjbWwwZVZObGNuWnBZMlY4ZXlKRFFTSTZJbFJsWVcxelgwRlVVRk5sY25acFkyVmZVMUJQVEU5R0lpd2lWaUk2SWpBdU1DNHdNREF3SWl3aVVDSTZJbGRwYmpNeUlpd2lRVTRpT2lKUGRHaGxjaUlzSWxkVUlqb3hNWDA9fDF8TDJOb1lYUnpMekU1T2pjek9Ua3dZakEwTFRKaFpEa3ROR1prTmkwNE0yRmlMVFZrWkdZM09UTmhabVF4WVY5aU1XRXdPRFE1TlMwMVpqUXlMVFEyWW1JdE9UZGxNaTB6TjJVell6VXpOVFZrT1RkQWRXNXhMbWRpYkM1emNHRmpaWE12YldWemMyRm5aWE12TVRjMk1Ua3hPREUxTkRrMU9BPT18NTYxNWY3NmZiMDNmNDRlY2YwZWEwOGRlMTg4MzVhNWZ8N2Y3YTAzYmE3YjJmNDQ1YWFiM2Q1ZGZjYzdhNThhOTk%3D&amp;sdata=ZHMwM1h4QVRGNWpRallHemtlcU5MTXlsdW1xVmg3NUJNVllHRUorMitQbz0%3D&amp;ovuser=8c8aade5-1c41-41de-8ea3-189ee2b481b3%2Cjill_mortensen%40keybank.com" target="_blank" rel="noopener">here</a> to provide feedback via our short survey.</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; color: red; font-size: 8pt;">KeyBank Internal Only: Do not forward externally.</span></p>

Shaik Imran
Tera Contributor
template.print('<br/><p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><strong>' 
            + gs.getMessage('Incident Manager: ') + current.u_recovery_manager + '</strong></span></p>');        

        if (!current.u_communication_specialist.nil()) {
            template.print('<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><strong>' 
                + gs.getMessage('Communication Specialist: ') + current.u_communication_specialist + '</strong></span></p>');
        }

        if (current.u_technology_owner != "") {
            template.print('<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><strong>' 
                + gs.getMessage('Technology Owner: ') + current.u_technology_owner + '</strong></span></p>');
        }

<p>
  <span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">
    <span data-teams="true">${mail_script:cic_footer}</span>
  </span>
</p>