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.

Updating Customer Visible Comments Font in Email Notifications

Sofija
Giga Expert

Hi All,

I am trying to update the font of customer visible comments that gets displayed in email notification. As system default it prints as Times New Roman, however, I need it to be Arial to match the content of email notifications they are called at. I read quite a few community feeds and SN wiki, and below is the email script that I could come the closest yet it does not work I would like to print all comments and just change the font size and face. Does anyone have any thoughts/suggestions?

printComments();
//this script was created in   order to update comments font

function printComments() {
    var comments = current.comments.getJournalEntry(-1);
    gs.log("Comments before replace:   " + comments);
    comments = comments.replace(/(\d+-\d+-\d+.*?)(\(\))/gim,"<hr /><strong>$1</strong>         <!--<sup>$2<\/sup>-->");   //this regular expression sometimes didn't work in my testing
          gs.log("Comments after replace:   " + comments);    
    var commentArray = comments.split("\n\n");
    template.print("<font face='arial,helvetica,sans-serif' font size='2'>" + cmtArray[-1] + "\n\n</font>");
}

I would greatly appreciate any ideas!

Kind Regards,

Kamile

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

Verify if this works



var notes = current.comments.getJournalEntry(-1);


var na = notes.split("\n\n");      


for (var i = 0; i < na.length; i++)    


  template.print("<font face='arial,helvetica,sans-serif' size='15'>" + na[i].toString() + "</font><br>");


View solution in original post

5 REPLIES 5

Kalaiarasan Pus
Giga Sage

Verify if this works



var notes = current.comments.getJournalEntry(-1);


var na = notes.split("\n\n");      


for (var i = 0; i < na.length; i++)    


  template.print("<font face='arial,helvetica,sans-serif' size='15'>" + na[i].toString() + "</font><br>");


It worked! Thank you!


I have tried this, and it works, but, I cannot set the font at "trebuchet ms" ans the size of "10".
It stay's the same as pre- editting. What to do? I have the "Rome" instance.

michellemmurtha
Giga Contributor

I have been experiencing the same issue and I recently discovered that some notifications worked and some did not.  This led me down a path where I analyzed the actual message HTML and was able to fix it!  

In a nutshell, the font type and size must be set within a <div> tag.  When it wasn't working, there were only paragraph tags <p></p>.

HTML Message text using <p> doesn't work:

<p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">Additional comments:&nbsp;</span><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">${comments}</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">&nbsp;</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">&nbsp;</span></p>

 

HTML Message text converted to <div> works:

<div><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">Additional comments:&nbsp;${comments}</span></div>
<div><span style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">&nbsp;</span></div>

 

 

This was tricky and elusive to figure out, however, I hope it saves someone else some time in the future!