How to create table in Notification Email Scripts

Rameshnathan
Tera Expert

Hi Friends

I have created one "Notification Email Scripts". for Change Report and i have to use this   email script in email notification with table format

1. This is my email script

baseUrl = gs.getProperty("glide.servlet.uri");

var gr = new GlideRecord("change_request");

gr.addEncodedQuery("active=true^assignment_group=dabb461adb373200a91fd001cf96195b");

gr.query();

if (gr.getRowCount() > 0) {

template.print("<br/><br/><br/>Change Request Report:<br/>");

while (gr.next()) {

template.print(" - <a href='" + baseUrl + gr.getLink() + "'>" + gr.getValue('number') + "</a> - " + " - " + gr.short_description + " - " + gr.getDisplayValue('state') + " -   "+ gr.getDisplayValue(' type') + "<br/>");

}

}

2. This above script output is below

Change Request Report:- CHG0030008 - - Short Description - New - null- CHG0030009 - - Short Description - Authorize - null- CHG0030010 - - Short Description - Authorize - null- CHG0030011 - - Short Description - Authorize - null- CHG0030012 - - Short Description - Authorize - null- CHG0030020 - - Short Description - New - null

3. I want to send this output as notification (email) in Table format any one can help me how to create table in email script

6 REPLIES 6

snajaykumar1234
Kilo Expert

HI Ramesh,



First you will set up condition when email to send,



next what it contains tab..you select table symbol.. i will share image of that symbol check once




table.png


what format you want , You can select..and what fields you want send that fields enter with in table.



This answer is helpful please mark helpful and correct mark as correct.



Thanks


Sanjay


Hi Sanjay


thanks for your reply


Actually i already set the notification and in that notification i have called the email script ${mail_script:Daily Report}


the output script is like this



Here how can i use that table ..?


find_real_file.png


Script Output is below


find_real_file.png


Hi Ramesh,



Please try with the below code:



var baseUrl = gs.getProperty("glide.servlet.uri");


var gr = new GlideRecord("change_request");


gr.addEncodedQuery("active=true");


gr.query();


if (gr.getRowCount() > 0) {


template.print('<table border="1"><th colspan="4" style="text-align:center">Change Request 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>'+ gr.getDisplayValue('type') +'</th></tr>');


}


template.print('/table');


}



Thanks,


Prateek Gupta


Hi Prateek Gupta



Thanks for your effort,, really its awesome and its working as i expected...



find_real_file.png



Thanks


Ramesh