carriage returns no longer converted for html email notifications in Geneva?

bcronrath
Kilo Guru

I have a particular set of email notifications that builds their body based on the event.parm1 passed in.   This string passed in contained newlines "\n" and in Fuji these were automatically converted to <br> so when the email sent it retained the newline.   Now after upgrading to Geneva it looks like they no longer do this, and I just get an ugly one line string.

Wondering if anyone knows why this is, and if from now on whenever using html email notifications I have to always specifically use <br> in my strings instead of \n?

Best regards,

Brian

1 ACCEPTED SOLUTION

Oh okay, well the link I posted in my previous comment explains that this is by design and will be like this going forward.



Administrators also have the option of converting existing email notifications to a rich HTML format (starting with the Eureka release). This format provides several advantages, including :


  • Raw HTML content is converted into a WYSIWYG format.
  • The content can be edited in a feature-rich HTML editor.
  • Mail scripts are condensed into a single, easy-to-read line that can be reused in multiple email notifications.
  • To prevent broken links, items like images and incidents, that are linked with URLs relative to a particular instance are converted to absolute links. For example, if an incident is linked using a relative URL, the link is converted to an absolute link.

Note


Note: The rich HTML format is the default for all new email notifications starting with the Eureka release.

4.1 Handling Line Breaks

Rich HTML provides additional control over line breaks in your email notifications and templates. To accommodate this, a Newlines to HTML check box is available in the Email Script form to ensure that <mail_script> scripts work the same after an upgrade to Eureka.



Selecting the Newlines to HTML check box indicates that the method for handling line breaks in earlier versions carries forward for email notifications and templates used in Eureka. When an email notification or template is converted to rich HTML, the Newlines to HTML check box is automatically selected.


For new mail scripts written in Eureka, it is a best practice to add correct HTML line breaks to template.print() statements.


If an email notification or template to rich HTML is not converted to rich HTML, newlines are automatically wrapped with <div> tags, the same as versions prior to Eureka. The old mail scripts still work; however, the administrator does not enjoy the benefits of working in the rich HTML format, and does not have as much control over exact HTML formatting.


View solution in original post

5 REPLIES 5

bcronrath
Kilo Guru

I've fixed it for now by changing the scripts to use <br /> instead of \n for now, just wondering if this is intended design change and I need to worry about future patches reverting it.


Have you checked the "Newlines to HTML" in your mail scripts?



Email Notifications - ServiceNow Wiki



Newlines to HTML.png


Hello Robert,



There is no email script for the affected email notification, the entire body is built from event.parm1


Hi Brian,



As Robert pointed out, trying the newlines to html would be a good option.   If you were to go to Notification Email Scripts and click on new, you would get the following code by default. You could run your template email from here as event.parm1 would be accessible.



(function runMailScript(current, template, email, email_action, event) {




                  // Add your code here




})(current, template, email, email_action, event);



Wiki for the above is below



Scripting for Email Notifications - ServiceNow Wiki



The being out of the box will help in future upgrades as well.