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

Jaspal Singh
Mega Patron
Mega Patron

We can use OOB Layout option that is available for Emails.  Lok for System Policy >> Email >> Layouts. Create one with required HTML data & then use the layout in the notifications.

 

Thanks,

Jaspal Singh

We are using the email layouts. But we have need for few different layouts, depending about case. 

 

In these layouts, we would like to use system properties.

 

find_real_file.png

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

 

 

Thank you! This solved my first issue! 

 

Followup question:

I want to use CSS also inside of email script.

Instead of: 

template.print('<style>.customer_button { font-family:"chevin-light", Helvetica,Arial,sans-serif; background-color: #FF6A10; border: none; color: white; padding: 10px 30px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; font-weight:bold; } .customer_button:hover { background-color: #ddd; color: black; }</style>');
template.print('<a href="'+link+'" class="customer_button">Button</a>');

I would like to use something like this:

var stylesheet = new GlideRecord('sp_css');
stylesheet.get('name', 'customer_email_notifications.css'); //Stylesheet for email styling
template.print('<div><style>' + stylesheet.css + '</style></div>');
template.print('<a href="'+link+'" class="customer_button">Button</a>');

But this doesn't work like this, what would be correct syntax?

We have several email notification for multiple modules and these all share one layout. Each email is then built from different email scripts which will bring all the information to the ticket, so we would need to be able to use css also inside of email script.