Amit Gujarathi
Giga Sage

HI @Elton2 ,
I trust you are doing great.
Please find the updated code for the same.

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

    // Define CSS Styles
    var styleBlock = '<style>' +
                     '.thStyle { font-size: 12px; border: 1px solid #000; background: #808000; }' +
                     '.tdStyle { border: 1px solid #000; text-align: center; }' +
                     '</style>';

    // Print the style block
    template.print(styleBlock);

    // Start the table
    template.print('<table>');
    template.print('<tr>');

    // Using class in table headers
    template.print('<th class="thStyle">Company</th>');
    template.print('<th class="thStyle">Department</th>');
    template.print('<th class="thStyle">Employees</th>');
    template.print('<th class="thStyle">Roles</th>');

    template.print('</tr>');

    var gr = new GlideRecord('ci_business_company');
    gr.query();
    while(gr.next()){

        template.print('<tr>');

        // Using class in table data
        template.print('<td class="tdStyle">' + gr.getDisplayValue('u_company') + '</td>');
        template.print('<td class="tdStyle">' + gr.getDisplayValue('u_department') + '</td>');
        template.print('<td class="tdStyle">' + gr.getDisplayValue('u_employees') + '</td>');
        template.print('<td class="tdStyle">' + gr.getDisplayValue('u_roles') + '</td>');

        template.print('</tr>');
    }

    template.print('</table>');

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

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post