Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

code transfer

Shaik Imran
Tera Contributor
<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

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

    // Add your code here
    template.print('<p><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><strong>' +
        gs.getMessage('Incident Manager: ') + '</strong>' + '<span style="font-weight:normal;">${u_recovery_manager.name}</span></span></p>');
    if (!current.u_communication_specialist.nil()) {
        template.print('<p><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><strong>' +
            gs.getMessage('Communication Specialist: ') + '</strong>' + '<span style="font-weight:normal;">${u_communication_specialist.name}</span></span></p>');
    }
    if (current.u_technology_owner != "") {
        template.print('<p><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;"><strong>' +
            gs.getMessage('Technology Owner: ') + '</strong>' + '<span style="font-weight:normal;">${u_technology_owner}</span></span></p>');
    }  

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

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

    // Collect each line into an array
    var lines = [];
    lines.push(
        '<strong>' + gs.getMessage('Incident Manager: ') + '</strong>' +
        '<span style="font-weight:normal;">' + current.u_recovery_manager.name + '</span>'
    );

    if (!current.u_communication_specialist.nil()) {
        lines.push(
            '<strong>' + gs.getMessage('Communication Specialist: ') + '</strong>' +
            '<span style="font-weight:normal;">' + current.u_communication_specialist.name + '</span>'
        );
    }

    if (current.u_technology_owner != "") {
        lines.push(
            '<strong>' + gs.getMessage('Technology Owner: ') + '</strong>' +
            '<span style="font-weight:normal;">' + current.u_technology_owner + '</span>'
        );
    }

    template.print(
        '<p><span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">' +
        lines.join('<br>') +
        '</span></p>'
    );

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

Shaik Imran
Tera Contributor
{{#if u_outage_end}}
  <!-- show Resolved and Duration rows -->
{{/if}}

// Code Generated by Sidekick is for learning and experimentation purposes only.
(function runMailScript(current, template, email, email_action, event) {
  var result = '';
  if (current.u_outage_end) {
    // Display the Resolved row
    result += '<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> ' + current.u_outage_end.getDisplayValue() + '</span></td></tr>';
    // Display the Duration row -- customize this line with your duration logic or variable
    result += '<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> ' + (current.u_cic_duration ? current.u_cic_duration : '') + '</span></td></tr>';
  }
  return result;
})(current, template, email, email_action, event);

Shaik Imran
Tera Contributor
(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('${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>';
  return table;
})(current, template, email, email_action, event);