Need help in formatting mail script font/style to be consistent with the Notification

Ljone
Giga Contributor

Hi Experts,

Need your help in formatting my mail script font/style to be consistent with the Notification we have.

We have a notification which per checking is using Arial font, size 12. This notification is calling a mail script. 

Now, when the notification is viewed they have different Font and Style. I have added below line of code to my mail script but not helping. template.print('<p><font size="3" color="#000000" face="arial">');

Please help!

 

Mail Script

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var item = new GlideRecord('sc_req_item');
    item.addQuery("sys_id", current.request_item);
    item.query();
 
    if (item.next()) {
 
        template.print('<p><font size="3" color="#000000" face="arial">');
        template.print("Transfer To Location: " + item.variable_pool.transfer_to_location.getDisplayValue() + "<br />");
        template.print("Transfer To Business Unit: " + item.variable_pool.transfer_to_bu.getDisplayValue() + "<br />");
        template.print("Transfer To Cost Centre: " + item.variable_pool.transfer_to_cost_center.getDisplayValue() + "<br />");
 
    }
})(current, template, email, email_action, event);

 

Notification Preview: 

find_real_file.png

 

HTML source code of Notification

<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Hi,</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">An Asset Transfer Request has been approved and the below task is required to be completed:&nbsp;</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;"><strong>${number} - ${short_description}</strong></span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Opened by: ${opened_by} on ${opened_at}</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Description: </span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">${description}</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Request: ${request_item.request.number} - ${request_item.request.short_description}</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Request item: ${request_item.number} - ${request_item.cat_item}</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Request opened: ${request_item.request.opened_at} &nbsp;</span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-family: arial, helvetica, sans-serif; color: #000000;">${mail_script:task_asset_transfer}</span></span></p>
<p>&nbsp;</p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">${mailto:mailto.close_task}</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align="center">${mail_script:ah_item_view_sc_task}</div>
<p>&nbsp;</p>
<p>&nbsp;</p>

1 ACCEPTED SOLUTION

Hello @Ljone ,

try with this script i think it applied but we did not apply the correct CSS try below code

template.print('<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;>")
template.print("Transfer To Location: " + item.variable_pool.transfer_to_location.getDisplayValue());
template.print( "<br /></p>");
template.print('<style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">') 
template.print("Transfer To Business Unit: " + item.variable_pool.transfer_to_bu.getDisplayValue());
template.print( "<br /></p>");
template.print('<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">') 
template.print( "Transfer To Cost Centre: "+ item.variable_pool.transfer_to_cost_center.getDisplayValue());
template.print( "<br /></p>");

View solution in original post

7 REPLIES 7

Hello @Ljone ,

try with this script i think it applied but we did not apply the correct CSS try below code

template.print('<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;>")
template.print("Transfer To Location: " + item.variable_pool.transfer_to_location.getDisplayValue());
template.print( "<br /></p>");
template.print('<style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">') 
template.print("Transfer To Business Unit: " + item.variable_pool.transfer_to_bu.getDisplayValue());
template.print( "<br /></p>");
template.print('<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">') 
template.print( "Transfer To Cost Centre: "+ item.variable_pool.transfer_to_cost_center.getDisplayValue());
template.print( "<br /></p>");

Thank you, Mohith! This solves my issue 🙂

Abhijit4
Mega Sage

You want email script text similar to text shown as part of notification, right? if yes then try below,

        template.print("<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Transfer To Location: " + item.variable_pool.transfer_to_location.getDisplayValue() + "<br /></p>");
        template.print("<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Transfer To Business Unit: " + item.variable_pool.transfer_to_bu.getDisplayValue() + "<br /></p>");
        template.print( "<p style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000;">Transfer To Cost Centre: "+ item.variable_pool.transfer_to_cost_center.getDisplayValue()+"</br ></p>");

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP