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.

How to adjust table borders in notification

Sironi
Kilo Sage

Hi All,

Please let me know how to adjust Table borders in notification

 

Sironi_0-1714865451623.png

template.print("<table border='1px solid black'>");
    var gr = new GlideRecord('incident');
    gr.addQuery('sys_id', current.sys_id.toString());
    gr.query();
    if (gr.next()) {
        template.print("<tr><td> Number </td><td>" + gr.number.toString() + "</td></tr>");
        template.print("<tr><td> Category </td><td>" + gr.category.toString() + "</td></tr>");
    }
    template.print("</table>");

 

Expecting Table format like below, can we make any changes to get it.

NumberINC0009003
CategoryInquiry




1 ACCEPTED SOLUTION

HI @Sironi 

Can you check with this

template.print("<style>table { border-collapse: collapse; } table.outer { border: 10px solid black; } table, th, td { border: 1px solid black; }</style>");

template.print("<table class='outer'>");

 

Mark it Helpful and Accept Solution!! If this helps you to understand.

View solution in original post

12 REPLIES 12

SK Chand Basha
Tera Sage
Tera Sage

Hi @Sironi Here you have to remove the border attribute from the <table> tag to avoid duplication.

 

template.print("<style>table { border-collapse: collapse; } table, th, td { border: 1px solid black; }</style>");
template.print("<table>");
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', current.sys_id.toString());
gr.query();
if (gr.next()) {
template.print("<tr><td> Number </td><td>" + gr.number.toString() + "</td></tr>");
template.print("<tr><td> Category </td><td>" + gr.category.toString() + "</td></tr>");
}
template.print("</table>");

 

Can you try with this once.

 

Mark it Helpful and Accept Solution!! If this helps you to understand.

Hi @SK Chand Basha ,

Sironi_0-1714884028534.png


Yes it is working...!
Can you please help me how come it is working
template.print("<style>table { border-collapse: collapse; } table, th, td { border: 1px solid black; }</style>");


Hi @Sironi Style tag contains CSS rule

  • table { border-collapse: collapse; }: This rule sets the border-collapse property of tables to collapse, which removes the spacing between table cells.
  • table, th, td { border: 1px solid black; }: This rule sets a solid black border with a width of 1 pixel for tables, table headers, and table cells.

In you case  generates an HTML table element with a border style applied directly through an HTML attribute.

 

Mark it Helpful and Accept Solution!! If this helps you to understand.

Thanks for your explanation , one last concern can we make out-border should be very solid black ? like below

Sironi_0-1714885694541.png