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.

table style in email script

raulron
Kilo Expert

Hi,

 

We have a mail script that is included in a notification. basically, it gathers all the approvals of a change request and displays them in a table with some data like last update date, etc.

 

we simply used template.print("<table>"); to achieve the table structure. But we need to "design" the table so it will look good.

 

i have tried using the style attribute in the table tag (like i would do in an email body. something like template.print("<table style="border: 1px solid #98bf21; padding: 3px 7px 2px 7px; background-color: #a7c942;">");

 

but when i check the syntax, i get an error that it is expecting a ) after the style=". i am guessing it is because it encounters a second ".

 

Is there a way to overcome this and use html style in mail scripts?

 

Thanks.

1 ACCEPTED SOLUTION

Thanks Tim,



Actually i did something a bit different, but it worked.



I did:



template.print('<table style="border: 1px solid #98bf21; padding: 3px 7px 2px 7px; background-color: #a7c942;">');


View solution in original post

4 REPLIES 4

Community Alums
Not applicable

I think you need to escape the " characters. You probably don't need to use the second " anyways. Try   this:



template.print("<table style=border: 1px solid #98bf21; padding: 3px 7px 2px 7px; background-color: #a7c942>");






Thanks Tim,



Actually i did something a bit different, but it worked.



I did:



template.print('<table style="border: 1px solid #98bf21; padding: 3px 7px 2px 7px; background-color: #a7c942;">');


marcguy
ServiceNow Employee
ServiceNow Employee

Something I've done before is just called a script include and include all of the HTML formatting in that.


i.e.


<mail script>


mail = new htmlEmail();


template.print(mail.send(current.sys_id));


</mail_script>


russell_miller
Kilo Guru

I take it a step further and use CSS to keep the styling consistent and reduce the need to update a bunch of templates for a simple change.



Posted a howto here: Styles into your emails...