code transfer
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid rgb(136, 136, 140);">
<tbody>
<!-- Table Title -->
<tr>
<td colspan="2" style="background-color: rgb(126, 128, 126); color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 15.0pt;">Critical Incident Communication</span>
</td>
</tr>
<!-- Priority Banner -->
<tr>
<td colspan="2" style="background-color: ${mail_script:im_cic_priority_color}; color: ${mail_script:im_cic_priority_textcolor}; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">Priority ${mail_script:im_cic_priority}</span>
</td>
</tr>
<!-- Incident hyperlink (WHITE row, no shading) -->
<tr>
<td colspan="2" style="border: 1px solid rgb(136, 136, 140); padding: 4px;">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">${URI_REF}</span>
</td>
</tr>
<!-- Priority (gray row) -->
<tr style="background-color: rgb(201, 201, 201);">
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Priority:</span> ${priority}
</span>
</td>
</tr>
<!-- Start (white row) -->
<tr>
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Start:</span> ${u_outage_start}
</span>
</td>
</tr>
<!-- Resolved (gray row) -->
<tr style="background-color: rgb(201, 201, 201);">
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Resolved:</span> ${u_outage_end}
</span>
</td>
</tr>
<!-- Duration (white row) -->
<tr>
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Duration:</span> ${mail_script:im_cic_duration}
</span>
</td>
</tr>
<!-- Systems Impacted (gray row) -->
<tr style="background-color: rgb(201, 201, 201);">
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Systems Impacted:</span> ${mail_script:im_cic_getAffectedProducts}
</span>
</td>
</tr>
<!-- Description (white row) -->
<tr>
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Description:</span> ${u_cic_description}
</span>
</td>
</tr>
<!-- Impact to Clients (gray, full width) -->
<tr style="background-color: rgb(201, 201, 201);">
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Impact to our Clients:</span> ${u_external_impact}
</span>
</td>
</tr>
<!-- Impact to Employees (white, full width) -->
<tr>
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<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(201, 201, 201);">
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Cause:</span> ${u_probable_cause}
</span>
</td>
</tr>
<!-- Completed Actions (white, full width) -->
<tr>
<td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
<span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
<span style="font-weight: bold;">Completed Actions<br></span> ${u_previous_activities}
</span>
</td>
</tr>
</tbody>
</table>
13 REPLIES 13
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
(function runMailScript(current, template, email, email_action, event) {
// Helper to check for empty values.
function isEmpty(val) {
return val == null || val === '' || (typeof val === 'string' && val.trim() === '');
}
var fields = [
// [Label, field value or mail_script reference, isMailScript]
['Priority', template.evaluateExpression('${priority}'), false],
['Start', template.evaluateExpression('${u_outage_start}'), false],
['Resolved', template.evaluateExpression('${u_outage_end}'), false],
['Duration', template.evaluateExpression('${mail_script:im_cic_duration}'), true],
['Systems Impacted', template.evaluateExpression('${mail_script:im_cic_getAffectedProducts}'), true],
['Description', template.evaluateExpression('${u_cic_description}'), false],
['Impact to our Clients', template.evaluateExpression('${u_external_impact}'), false],
['Impact to our Employees', template.evaluateExpression('${u_internal_impact}'), false],
['Cause', template.evaluateExpression('${u_probable_cause}'), false],
['Completed Actions<br>', template.evaluateExpression('${u_previous_activities}'), false]
];
var table = '';
table += '<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid rgb(136,136,140);"><tbody>';
// Title Row
table += '<tr><td colspan="2" style="background-color: rgb(126,128,126); color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid rgb(136,136,140);"><span style="font-family: Aptos, sans-serif; font-size: 15.0pt;">Critical Incident Communication</span></td></tr>';
// Priority Banner
/*//var priorityColor = template.evaluateExpression(prioritybgcolor());
//var priorityText = template.evaluateExpression(prioritytextcolor());
//var priorityLevel = template.evaluateExpression(incpriority());
table += '<tr><td colspan="2" style="background-color: ' + prioritybgcolor(current) + '; color: ' + prioritytextcolor(current) + '; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">Priority ' + incpriority(current) + '</span></td></tr>';*/
var priorityColor = template.evaluateExpression('${mail_script:im_cic_priority_color}');
var priorityText = template.evaluateExpression('${mail_script:im_cic_priority_textcolor}');
var priorityLevel = template.evaluateExpression('${mail_script:im_cic_priority}');
table += '<tr><td colspan="2" style="background-color: ' + priorityColor + '; color: ' + priorityText + '; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">Priority ' + priorityLevel + '</span></td></tr>';
// Incident Number/Hyperlink Row (alternating color will be handled with row count logic)
var uriRef = template.evaluateExpression('${URI_REF}');
var colorToggle = false; // start with white after banners
if (!isEmpty(uriRef)) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">' + uriRef + '</span></td></tr>';
colorToggle = !colorToggle;
}
// Dynamically build each non-empty row with alternating color
for (var i = 0; i < fields.length; i++) {
var label = fields[i][0];
var value = fields[i][1];
// Special case: Duration/Resolved - only show if 'Resolved' is present
//if (label === 'Resolved' && isEmpty(value)) continue;
//if (label === 'Duration' && isEmpty(fields[2][1])) continue; // If no Resolved, skip Duration
if (!isEmpty(value)) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140);"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">' + label + ':</span> ' + value + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
table += '</tbody></table>';
template.print(table);
function prioritybgcolor(current) {
var bgcolor = '';
var bgpriority = current.priority + '';
if (priority == '2') color = '#C00000';
else if (priority == '3') color = '#E97132';
else if (priority == '4') color = '#FFFF66';
return bgcolor;
}
function prioritytextcolor(current) {
var textcolor = '';
var textpriority = current.priority + '';
if (textpriority == '2') color = '#FFFFFF';
else if (textpriority == '3') color = '#FFFFFF';
else if (textpriority == '4') color = '#000000';
return textcolor;
}
function incpriority(current) {
var priority = current.priority;
if (priority == 2) {
return "1";
}
if (priority == 3) {
return "2";
}
if (priority == 4) {
return "3";
}
}
})(current, template, email, email_action, event);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
(function runMailScript(current, template, email, email_action, event) {
// Helper to check for empty values.
var dur = '';
if (!current.u_outage_start.nil() && !current.u_outage_end.nil()) {
dur = calcDiff(current.u_outage_start.getDisplayValue(), current.u_outage_end.getDisplayValue());
}
var aff = '';
if(getAffectedProducts(current.sys_id)){
aff = getAffectedProducts(current.sys_id);
}
var fields = [
// [Label, field value or mail_script reference, isMailScript]
['Priority', current.priority.getDisplayValue(), false],
['Start', current.u_outage_start, false],
['Resolved', current.u_outage_end, false],
['Duration', dur, true],
['Systems Impacted', aff, true],
['Description', current.u_cic_description, false],
['Impact to our Clients', current.u_external_impact, false],
['Impact to our Employees', current.u_internal_impact, false],
['Cause', current.u_probable_cause, false],
['Completed Actions', current.u_previous_activities, false]
];
var table = '';
table += '<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid rgb(136,136,140);"><tbody>';
// Title Row
table += '<tr><td colspan="2" style="background-color: rgb(126,128,126); color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid rgb(136,136,140);"><span style="font-family: Aptos, sans-serif; font-size: 15.0pt;">Critical Incident Communication</span></td></tr>';
// Priority Banner
table += '<tr><td colspan="2" style="background-color: ' + prioritybgcolor(current) + '; color: ' + prioritytextcolor(current) + '; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">Priority ' + incpriority(current) + '</span></td></tr>';
// Incident Number/Hyperlink Row (alternating color will be handled with row count logic)
var colorToggle = false; // start with white after banners
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">${URI_REF}</span></td></tr>';
colorToggle = !colorToggle;
// Dynamically build each non-empty row with alternating color
for (var i = 0; i < fields.length; i++) {
var label = fields[i][0];
var value = fields[i][1];
// Special case: Duration/Resolved - only show if 'Resolved' is present
//if (label === 'Resolved' && isEmpty(value)) continue;
if (label === 'Duration' && isEmpty(fields[2][1])) continue; // If no Resolved, skip Duration
if (!isEmpty(value)) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140);"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">' + label + ':</span> ' + value + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
table += '</tbody></table>';
template.print(table);
function isEmpty(val) {
return val == null || val === '' || (typeof val === 'string' && val.trim() === '');
}
function prioritybgcolor(current) {
var bgcolor = '';
var bgpriority = current.priority + '';
if (bgpriority == '2') bgcolor = '#C00000';
else if (bgpriority == '3') bgcolor = '#E97132';
else if (bgpriority == '4') bgcolor = '#FFFF66';
return bgcolor;
}
function prioritytextcolor(current) {
var textcolor = '';
var textpriority = current.priority + '';
if (textpriority == '2') textcolor = '#FFFFFF';
else if (textpriority == '3') textcolor = '#FFFFFF';
else if (textpriority == '4') textcolor = '#000000';
return textcolor;
}
function incpriority(current) {
var priority = current.priority;
if (priority == 2) {
return "1";
}
if (priority == 3) {
return "2";
}
if (priority == 4) {
return "3";
}
}
function calcDiff(start, end) {
var durr = gs.dateDiff(start, end, false);
durr = durr.toString().replace(/:/g, ' ').split(' ');
var duration = '';
switch (durr.length) {
case 1:
duration = durr[0] + ' Seconds.';
break;
case 2:
duration = durr[0] + ' Minutes ' + durr[1] + ' Seconds.';
break;
case 3:
duration = durr[0] + ' Hours, ' + durr[1] + ' Minutes ' + durr[2] + ' Seconds.';
break;
case 4:
duration = durr[0] + ' Days, ' + durr[1] + ' Hours, ' + durr[2] + ' Minutes ' + durr[3] + ' Seconds.';
break;
}
return duration;
}
function getAffectedProducts(current) {
var pdct = [];
var gr = new GlideRecord("task_ci");
gr.addQuery('task', current);
gr.query();
while (gr.next()) {
if (!gr.ci_item.u_tla.nil()) {
pdct.push(gr.ci_item.u_tla.getDisplayValue());
}
}
pdct = pdct.sort();
pdct = pdct.toString();
//add spaces to the string for readability
pdct = pdct.replace(/,/g, ', ');
return pdct;
}
})(current, template, email, email_action, event);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
(function runMailScript(current, template, email, email_action, event) {
/**** FIELD DEFINITIONS PER EVENT TYPE (NO DEFAULT FIELDS) ****/
// Map your event name/key (e.g. 'event1', 'event2').
// No '*' property here: only events you specify will show fields.
var fieldDefinitions = {
'event1': [
['Priority', function() { return current.priority ? current.priority.getDisplayValue() : ''; }],
['Start', function() { return current.u_outage_start ? current.u_outage_start.getDisplayValue() : ''; }],
['Resolved', function() { return current.u_outage_end ? current.u_outage_end.getDisplayValue() : ''; }],
['Duration', durationField],
['Systems Impacted', getAffectedProductsField]
],
'event2': [
['Description', function() { return current.u_cic_description ? current.u_cic_description + '' : ''; }],
['Impact to our Clients', function() { return current.u_external_impact ? current.u_external_impact + '' : ''; }]
]
// Add more events and their field sets as needed
};
// Get event key from notification, or blank if not found
var eventKey = (typeof event !== 'undefined' && event && event.name) ? event.name : '';
var fields = fieldDefinitions[eventKey];
// Start table markup (header and priority always shown)
var table = '';
table += '<table style="width:100%;border-collapse:collapse;font-family:Arial,sans-serif;border:1px solid #88888c;"><tbody>';
table += '<tr><td colspan="2" style="background-color:#7E807E;color:white;font-size:1.5em;font-weight:bold;padding:8px;border:1px solid #88888c;"><span style="font-family:Aptos,sans-serif;font-size:15.0pt;">Critical Incident Communication</span></td></tr>';
table += '<tr><td colspan="2" style="background-color:' + prioritybgcolor(current) + ';color:' + prioritytextcolor(current) + ';font-weight:bold;padding:4px;border:1px solid #88888c;border-top:none;"><span style="font-family:Aptos,sans-serif;font-size:12.0pt;">Priority ' + incpriority(current) + '</span></td></tr>';
// Incident URI Row (optional—remove if you want to hide when not in events)
var colorToggle = false;
var uriRef = template.evaluateExpression('${URI_REF}');
if (!isEmpty(uriRef)) {
table += '<tr' + (colorToggle ? ' style="background-color:#C9C9C9;"' : '') + '><td colspan="2" style="border:1px solid #88888c;padding:4px;"><span style="font-family:Aptos,sans-serif;font-size:12.0pt;">' + uriRef + '</span></td></tr>';
colorToggle = !colorToggle;
}
/**** RENDER FIELDS ONLY IF EVENT IS CONFIGURED ****/
if (fields && fields.length > 0) {
for (var i = 0; i < fields.length; i++) {
var label = fields[i][0];
var value = '';
try {
value = fields[i][1]();
} catch (e) { value = ''; }
// Duration only if valid, Resolved only if value present
if (label === 'Duration' && isEmpty(value)) continue;
if (label === 'Resolved' && isEmpty(value)) continue;
if (!isEmpty(value)) {
table += '<tr' + (colorToggle ? ' style="background-color:#C9C9C9;"' : '') +
'><td colspan="2" style="border:1px solid #88888c;"><span style="font-family:Aptos,sans-serif;font-size:12.0pt;"><span style="font-weight:bold;">'
+ label + ':</span> ' + value +
'</span></td></tr>';
colorToggle = !colorToggle;
}
}
}
// else: No matching event, only show title/priority/URI (no field rows)
table += '</tbody></table>';
template.print(table);
/*** HELPER FUNCTIONS ***/
function isEmpty(val) {
if (val === null || val === undefined) return true;
if (typeof val === 'string' && val.trim() === '') return true;
if (typeof val === 'object' && typeof val.getDisplayValue === 'function') return val.getDisplayValue().trim() === '';
return false;
}
function prioritybgcolor(current) {
var bgpriority = current.priority + '';
if (bgpriority == '2') return '#C00000';
if (bgpriority == '3') return '#E97132';
if (bgpriority == '4') return '#FFFF66';
return '#888888';
}
function prioritytextcolor(current) {
var textpriority = current.priority + '';
if (textpriority == '2' || textpriority == '3') return '#FFFFFF';
if (textpriority == '4') return '#000000';
return '#FFFFFF';
}
function incpriority(current) {
var p = current.priority+'';
if (p == '2') return '1';
if (p == '3') return '2';
if (p == '4') return '3';
return p;
}
// Duration function only if BOTH start and resolved are present, otherwise blank
function durationField() {
if (
current.u_outage_start &&
current.u_outage_end &&
!current.u_outage_start.nil() &&
!current.u_outage_end.nil()
) {
return calcDiff(current.u_outage_start.getDisplayValue(), current.u_outage_end.getDisplayValue());
}
return '';
}
// Field function: comma-separated, sorted, affected products
function getAffectedProductsField() {
var pdct = [];
var gr = new GlideRecord("task_ci");
gr.addQuery('task', current.sys_id);
gr.query();
while (gr.next()) {
if (!gr.ci_item.u_tla.nil()) {
pdct.push(gr.ci_item.u_tla.getDisplayValue());
}
}
pdct = pdct.sort();
return pdct.join(', ');
}
// ServiceNow duration formatting logic from your script
function calcDiff(start, end) {
var durr = gs.dateDiff(start, end, false);
durr = durr.toString().replace(/:/g, ' ').split(' ');
var duration = '';
switch (durr.length) {
case 1: duration = durr[0] + ' Seconds.'; break;
case 2: duration = durr[0] + ' Minutes ' + durr[1] + ' Seconds.'; break;
case 3: duration = durr[0] + ' Hours, ' + durr[1] + ' Minutes ' + durr[2] + ' Seconds.'; break;
case 4: duration = durr[0] + ' Days, ' + durr[1] + ' Hours, ' + durr[2] + ' Minutes ' + durr[3] + ' Seconds.'; break;
}
return duration;
}
})(current, template, email, email_action, event);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
(function runMailScript(current, template, email, email_action, event) {
var table = '';
table += '<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid rgb(136,136,140);"><tbody>';
// Title Row
table += '<tr><td colspan="2" style="background-color: rgb(126,128,126); color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid rgb(136,136,140);"><span style="font-family: Aptos, sans-serif; font-size: 15.0pt;">Critical Incident Communication</span></td></tr>';
// Priority Banner
table += '<tr><td colspan="2" style="background-color: ' + prioritybgcolor(current) + '; color: ' + prioritytextcolor(current) + '; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">' + incpriority(current) + '</span></td></tr>';
// Incident Number/Hyperlink Row (alternating color will be handled with row count logic)
var colorToggle = false; // start with white after banners
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">${URI_REF}</span></td></tr>';
colorToggle = !colorToggle;
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Priority:</span> ' + current.priority.getDisplayValue() + '</span></td></tr>';
colorToggle = !colorToggle;
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Start:</span> ' + current.u_outage_start + '</span></td></tr>';
colorToggle = !colorToggle;
if (email_action.event_name.getDisplayValue() != 'im_cic_new') {
if (!current.u_outage_end.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Resolved:</span> ' + current.u_outage_end + '</span></td></tr>';
colorToggle = !colorToggle;
}
var duration = '';
if (!current.u_outage_start.nil() && !current.u_outage_end.nil()) {
duration = calcDiff(current.u_outage_start.getDisplayValue(), current.u_outage_end.getDisplayValue());
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Duration:</span> ' + duration + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
var aff = '';
aff = getAffectedProducts(current.sys_id);
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Systems Impacted:</span> ' + aff + '</span></td></tr>';
colorToggle = !colorToggle;
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Description:</span> ' + current.u_cic_description + '</span></td></tr>';
colorToggle = !colorToggle;
if (email_action.event_name.getDisplayValue() != 'im_cic_new') {
if (!current.u_external_impact.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Impact to our Clients:</span> ' + current.u_external_impact + '</span></td></tr>';
colorToggle = !colorToggle;
}
if (!current.u_internal_impact.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Impact to our Employees:</span> ' + current.u_internal_impact + '</span></td></tr>';
colorToggle = !colorToggle;
}
if (!current.u_probable_cause.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Cause:</span> ' + current.u_probable_cause + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
if (email_action.event_name.getDisplayValue() != 'im_cic_new' && email_action.event_name.getDisplayValue() != 'im_cic_update') {
if (!current.u_resolution_activities.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Resolution Activities:</span> ' + current.u_resolution_activities + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
if (email_action.event_name.getDisplayValue() == 'im_cic_update' || email_action.event_name.getDisplayValue() == 'sno.im.cic.restore.verify') {
if (!current.u_previous_activities.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Completed Actions:</span> ' + current.u_previous_activities + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
if (email_action.event_name.getDisplayValue() == 'im_cic_pis') {
if (!current.u_previous_activities.nil()) {
table += '<tr' + (colorToggle ? ' style="background-color: rgb(201,201,201);"' : '') + '><td colspan="2" style="border: 1px solid rgb(136,136,140); padding: 4px;"><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><span style="font-weight: bold;">Action Items:</span> ' + current.u_action_items + '</span></td></tr>';
colorToggle = !colorToggle;
}
}
table += '</tbody></table>';
template.print(table);
function prioritybgcolor(current) {
var bgcolor = '';
var bgpriority = current.priority + '';
if (email_action.event_name.getDisplayValue() == 'im_cic_pis') bgcolor = '#00b050';
else if (bgpriority == '2') bgcolor = '#C00000';
else if (bgpriority == '3') bgcolor = '#E97132';
else if (bgpriority == '4') bgcolor = '#FFFF66';
return bgcolor;
}
function prioritytextcolor(current) {
var textcolor = '';
var textpriority = current.priority + '';
if (email_action.event_name.getDisplayValue() == 'im_cic_pis') textcolor = '#FFFFFF';
else if (textpriority == '2') textcolor = '#FFFFFF';
else if (textpriority == '3') textcolor = '#FFFFFF';
else if (textpriority == '4') textcolor = '#000000';
return textcolor;
}
function incpriority(current) {
var priority = current.priority;
if (email_action.event_name.getDisplayValue() == 'im_cic_pis') {
return "Post Incident Summary";
} else if (priority == 2) {
return "Priority 1";
} else if (priority == 3) {
return "Priority 2";
} else if (priority == 4) {
return "Priority 3";
}
}
function calcDiff(start, end) {
var durr = gs.dateDiff(start, end, false);
durr = durr.toString().replace(/:/g, ' ').split(' ');
var duration = '';
switch (durr.length) {
case 1:
duration = durr[0] + ' Seconds.';
break;
case 2:
duration = durr[0] + ' Minutes ' + durr[1] + ' Seconds.';
break;
case 3:
duration = durr[0] + ' Hours, ' + durr[1] + ' Minutes ' + durr[2] + ' Seconds.';
break;
case 4:
duration = durr[0] + ' Days, ' + durr[1] + ' Hours, ' + durr[2] + ' Minutes ' + durr[3] + ' Seconds.';
break;
}
return duration;
}
function getAffectedProducts(current) {
var pdct = [];
var gr = new GlideRecord("task_ci");
gr.addQuery('task', current);
gr.query();
while (gr.next()) {
if (!gr.ci_item.u_tla.nil()) {
pdct.push(gr.ci_item.u_tla.getDisplayValue());
}
}
pdct = pdct.sort();
pdct = pdct.toString();
//add spaces to the string for readability
pdct = pdct.replace(/,/g, ', ');
return pdct;
}
})(current, template, email, email_action, event);