Using System properties in email layouts

Riikkab
Tera Contributor

Is it possible to read System properties from email layout?

We would like to read ie. fonts and notification colors from system properties instead of hardcoding those to the email layout. I haven't figured out a way to access system properties from email layouts, is there a way?

Here is example:

<td style=" padding: 15px 0px 0px 0px; text-align: left; font-family: Helvetica,Arial,sans-serif; color:#323232;"> 
${notification:body}
</td>

We would like to define the font-family and the color in sys_properties, so we could re use the same values and upate all at once if there is any changes.

1 ACCEPTED SOLUTION

Swapnil Soni1
Giga Guru

Hi,

In the "Message HTML", usually I call a default stylesheet just in case of I need to change any HTML tag (font, size, etc).
  • Add <p>${mail_script:notification_email.styles}</p>.
To use a mail script, 
  • Navigate to System Notification > Email > Notifications Email Scripts
  • Click New: "Notification_email.styles"
  • On the your email script:
    var stylesheet = new GlideRecord ('sp_css');
    stylesheet.get('name','company_email_notifications.css'); //Stylesheet for email styling
    template.print('<div><style>' + stylesheet.css + '</style></div>');

3. Navigate to System Notification > Email > Notifications.
4. Open the email notification record that should use the template.
5. Navigate to the What it will contain section.
6. From the Email Template field, select the appropriate template.
7. Click Update.

 

Please mark correct or helpful if this helps.

Thanks

Swapnil

 

 

View solution in original post

7 REPLIES 7

Hey,

Feel good that it's helpful to you. And for further issue please go through these links so you get an idea to use CSS in email scripting

https://community.servicenow.com/community?id=community_blog&sys_id=438c2ae1dbd0dbc01dcaf3231f9619fe

 

https://community.servicenow.com/community?id=community_blog&sys_id=cd9daa69dbd0dbc01dcaf3231f961963

 

If this helpful please mark helpful.

Thanks

Swapnil

Hi Soni,

Where the email script should be pasted in Notification or email template??

I don't see any style sheet property "company_email_notifications.css" in my instance. Can you please help with that.

Thank you 🙂

DirkRedeker
Mega Sage

Hi

Have you tried to use Mail Scripts in your Layout? Maybe you just can use it like in the Notification itself?

Let me know.

BR

Dirk