nameisnani
Mega Sage

@Ankur Bawiskar 

 

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

    (function() {
        function getColor(status) {
            if (status == 'DOWN') return '#ff4d4d'; // Red
            if (status == 'UP') return '#4CAF50'; // Green
            return '#d9d9d9'; // Grey (for unknown)
        }

        var html = '';
        html += '<table border="1" cellpadding="6" cellspacing="0" style="border-collapse:collapse;width:80%;">';
        html += '<tr style="background-color:#f2f2f2;"><th>Field</th><th>Status</th></tr>';

        // MID Server - Prod
        html += '<tr>';
        html += '<td><b>MID Server - Prod</b></td>';
        html += '<td style="background-color:' + getColor(current.u_mid_prod_status) + ';color:white;text-align:center;">' +
            current.u_mid_prod_status + '</td>';
        html += '</tr>';

        // MID Server - Stag
        html += '<tr>';
        html += '<td><b>MID Server - Stag</b></td>';
        html += '<td style="background-color:' + getColor(current.u_mid_stag_status) + ';color:white;text-align:center;">' +
            current.u_mid_stag_status + '</td>';
        html += '</tr>';

        // MID Server - Dev
        html += '<tr>';
        html += '<td><b>MID Server - Dev</b></td>';
        html += '<td style="background-color:' + getColor(current.u_mid_dev_status) + ';color:white;text-align:center;">' +
            current.u_mid_dev_status + '</td>';
        html += '</tr>';

        html += '</table>';
        html += '<br>Regards,<br><b>ServiceNow Health Check Automation</b>';

        return html;
    })();


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

 

this is the script i tired