Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Table in notification via Email Script

Gayathri5
Tera Guru

Hi,

 

I am attaching a screenshot of output of my requirement and it is working fine,but i want to print Incident,Shortdescription and priority for my columns.How to do that?

On top of each column i need to provide name.

 

I have tried adding <td> but didn achieve it pls somebody help.

 

if (gr.getRowCount() > 0) {


template.print('<table border="1"><th colspan="4" style="text-align:center">Incident Report </th> ');

while (gr.next()) {

template.print('<tr><th><a href=' + baseUrl + gr.getLink() + '>' + gr.getValue('number') + '</a></th><th>' + gr.short_description + '</th><th>' + gr.getDisplayValue('state') + '</th><th>' + '</th></tr>');


}

 

Regards,

Gayathri

 

1 ACCEPTED SOLUTION

Sai Kumar B
Mega Sage

Hi @Gayathri 

You can add the below format inside your if condition and modify the columns accordingly

template.print('<br />');
    template.print('<table style="height: 23px;" width="100%"><tbody><tr><td style="background-color: #0e5399;"><font color="#FFFFFF"><strong>Closed Projects</strong></font></td></tr></tbody></table>');
    var tbl = '<table style="height: 293px;" width="100%"><tbody>';
    //template.print(tbl);

    var tab = '<table style="width: 100%; border-collapse : collapse; " border = "2" cellpadding = "10"> <tbody>' +
        '<tr>' + '<td style="background-color: #aeaeae;">' + '<b>Number</b>' + '</td>' +
        '<td style="background-color: #aeaeae;">' + '<b>State</b>' + '</td>' +
        '<td style="background-color: #aeaeae;">' + '<b>Short description</b>' + '</td>' +
        '<td style="background-color: #aeaeae;">' + '<b>Caller</b>' + '</td>' +
        '</tr>';
    template.print(tab);

        var clsed = '<tr>' + '<td>' + gr.number + '</td>' +
            '<td>' + gr.getDisplayValue('state') + '</td>' +
            '<td>' + gr.getValue('short_description') + '</td>' +
            '<td>' + gr.caller_id.name + '</td>' +
            '</tr>';
        template.print(clsed);
    }

    var tab_end = '</tbody> </table>';
    template.print(tab_end);

View solution in original post

3 REPLIES 3

Wayne Richmond
Tera Guru
if (gr.getRowCount() > 0) {

template.print('<table border="1"><tr><th colspan="4" style="text-align:center">Incident Report </th></tr><tr><th><p>Incident</p></th><th><p>Short Description</p></th><th><p>State</p></th><th></th></tr> ');

while (gr.next()) {

template.print('<tr><th><a href=' + baseUrl + gr.getLink() + '>' + gr.getValue('number') + '</a></th><th>' + gr.short_description + '</th><th>' + gr.getDisplayValue('state') + '</th><th>' + '</th></tr>');


}

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

I think that should do it (just updated it as I didn't spot the 4th column).

Hi wayne,

 

Is this HTML table creation syntax we have to use? Thanks its working as expected.

 

 

Regards,

Gayathri

Sai Kumar B
Mega Sage

Hi @Gayathri 

You can add the below format inside your if condition and modify the columns accordingly

template.print('<br />');
    template.print('<table style="height: 23px;" width="100%"><tbody><tr><td style="background-color: #0e5399;"><font color="#FFFFFF"><strong>Closed Projects</strong></font></td></tr></tbody></table>');
    var tbl = '<table style="height: 293px;" width="100%"><tbody>';
    //template.print(tbl);

    var tab = '<table style="width: 100%; border-collapse : collapse; " border = "2" cellpadding = "10"> <tbody>' +
        '<tr>' + '<td style="background-color: #aeaeae;">' + '<b>Number</b>' + '</td>' +
        '<td style="background-color: #aeaeae;">' + '<b>State</b>' + '</td>' +
        '<td style="background-color: #aeaeae;">' + '<b>Short description</b>' + '</td>' +
        '<td style="background-color: #aeaeae;">' + '<b>Caller</b>' + '</td>' +
        '</tr>';
    template.print(tab);

        var clsed = '<tr>' + '<td>' + gr.number + '</td>' +
            '<td>' + gr.getDisplayValue('state') + '</td>' +
            '<td>' + gr.getValue('short_description') + '</td>' +
            '<td>' + gr.caller_id.name + '</td>' +
            '</tr>';
        template.print(clsed);
    }

    var tab_end = '</tbody> </table>';
    template.print(tab_end);