notification in table format

Shaik Imran
Tera Contributor

How to create a notification in table format

5 REPLIES 5

Shaik Imran
Tera Contributor
<table style="width:100%; border-collapse:collapse; font-family:Arial,sans-serif;">
  <tr>
    <td colspan="2" style="background-color:#88888C; color:white; font-size:1.5em; font-weight:bold; padding:8px;">
      Critical Incident Communication
    </td>
  </tr>
  <tr>
    <td colspan="2" style="background-color:#d0021b; color:white; font-weight:bold; padding:6px;">
      Priority 1
    </td>
  </tr>
  <tr>
    <td colspan="2" style="padding-top:4px; padding-bottom:4px;">
      <a href="{incident_link}" style="color:#0066cc; text-decoration:underline;">{incident_number}</a> 
      <span style="color:#087a10; background-color:#b6f5bc; font-style:italic;">
        (We now want the Incident # hyperlinked to the record in SNO)
      </span>
    </td>
  </tr>
  <tr>
    <td style="font-weight:bold; width:130px;">Priority:</td>
    <td>1 – Critical <span style="color:#087a10; background-color:#b6f5bc;">{priority_change}</span></td>
  </tr>
  <tr>
    <td style="font-weight:bold;">Start:</td>
    <td>{start_time} <span style="color:#087a10; background-color:#b6f5bc;">{start_time_change}</span></td>
  </tr>
  <tr>
    <td style="font-weight:bold;">Resolved:</td>
    <td>{resolved_time} <span style="color:#087a10; background-color:#b6f5bc;">{resolved_time_change}</span></td>
  </tr>
  <tr>
    <td style="font-weight:bold;">Duration:</td>
    <td>{duration} <span style="color:#087a10; background-color:#b6f5bc;">{duration_change}</span></td>
  </tr>
  <tr>
    <td style="font-weight:bold;">Systems Impacted:</td>
    <td>{systems_impacted} <span style="color:#a88400; background-color:#fafd9b; font-style:italic;">(This should now be in alphabetical order)</span></td>
  </tr>
  <tr>
    <td style="font-weight:bold;">Description:</td>
    <td>{description} <span style="color:#087a10; background-color:#b6f5bc;">{description_change}</span></td>
  </tr>
  <tr>
    <td colspan="2" style="font-weight:bold; padding-top:12px;">
      Impact to our Clients:
    </td>
  </tr>
  <tr>
    <td colspan="2" style="font-size:0.99em;">
      {client_impact} 
      <span style="color:#a88400; background-color:#fafd9b; font-style:italic;">
        (Verbiage change "Impact to our Clients", however the place it comes from on the table remains the same...)
      </span>
    </td>
  </tr>
  <tr>
    <td colspan="2" style="font-weight:bold; padding-top:12px;">
      Impact to our Employees:
    </td>
  </tr>
  <tr>
    <td colspan="2" style="font-size:0.99em;">
      {employee_impact}
      <span style="color:#a88400; background-color:#fafd9b; font-style:italic;">
        (Verbiage change “Impact to our Employees”, however the place it comes from on the table remains the same...)
      </span>
    </td>
  </tr>
</table>

You, 13 min



(function runMailScript(current) {
  var priority = current.priority.getDisplayValue();
  var priColor = '#A7A8AA'; // default gray

  if (priority == '1 - Critical') {
    priColor = '#d0021b'; // red
  } else if (priority == '2 - High') {
    priColor = '#ED8B00'; // orange
  } else if (priority == '3 - Moderate') {
    priColor = '#FFD100'; // yellow
  } else if (priority == '4 - Low') {
    priColor = '#A7A8AA'; // gray
  }
  template.print('<g:priColor>' + priColor + '</g:priColor>');
})(current);

<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid #88888c;">
<tbody><!-- Table Title -->
<tr>
<td style="background-color: #88888c; color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid #88888c;" colspan="2">Critical Incident Communication</td>
</tr>
<!-- Priority Banner -->
<tr>
<td style="background-color: ${mail_script:prioritycolor}; color: white; font-weight: bold; font-size: 1.2em; padding: 8px; border: 1px solid #88888c; border-top: none;" colspan="2">Priority ${mail_script:Priority}</td>
</tr>
<!-- Incident hyperlink (WHITE row, no shading) -->
<tr>
<td style="border: 1px solid #88888c; padding: 4px;" colspan="2">${URI_REF}</td>
</tr>
<!-- Priority (gray row) -->
<tr style="background-color: #f2f2f2;">
<td style="border: 1px solid #88888c;"><span style="font-weight: bold;">Priority:</span> ${priority}</td>
</tr>
<!-- Start (white row) -->
<tr>
<td style="font-weight: bold; border: 1px solid #88888c;">Start:</td>
</tr>
<!-- Resolved (gray row) -->
<tr style="background-color: #f2f2f2;">
<td style="font-weight: bold; border: 1px solid #88888c;">Resolved:</td>
</tr>
<!-- Duration (white row) -->
<tr>
<td style="font-weight: bold; border: 1px solid #88888c;">Duration:</td>
</tr>
<!-- Systems Impacted (gray row) -->
<tr style="background-color: #f2f2f2;">
<td style="font-weight: bold; border: 1px solid #88888c;">Systems Impacted:</td>
</tr>
<!-- Description (white row) -->
<tr>
<td style="font-weight: bold; border: 1px solid #88888c;">Description:</td>
</tr>
<!-- Impact to Clients (gray, full width) -->
<tr style="background-color: #f2f2f2;">
<td style="font-weight: bold; border: 1px solid #88888c;">Impact to our Clients:</td>
</tr>
<!-- Impact to Employees (white, full width) -->
<tr>
<td style="font-weight: bold; border: 1px solid #88888c;">Impact to our Employees:</td>
</tr>
<!-- Cause (gray, full width) -->
<tr style="background-color: #f2f2f2;">
<td style="font-weight: bold; border: 1px solid #88888c;">Cause:</td>
</tr>
<!-- Resolution Activities (white, full width) -->
<tr>
<td style="font-weight: bold; border: 1px solid #88888c;">Resolution Activities:</td>
</tr>
</tbody>
</table>

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

    // Add your code here
    var color = '#88888c';
    var p = current.priority + '';
    if (p == '1') color = '#d0021b';
    else if (p == '2') color = '#f5a623';
    else if (p == '3') color = '#f8e71c';
    else if (p == '4') color = '#7ed321';
    else if (p == '5') color = '#4a90e2';
    template.print(color);
})(current, template, email, email_action, event);

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