Quick Message HTML - ServiceNow inserting line breaks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2014 06:51 AM
I'm experimenting with using the Quick Message for special announcement templates. ServiceNow seems to be overriding the HTML format of my quick messages, and every message manually typed and sent from the email client with line breaks <br>.
For example, my Quick Message template message body is:
<p>Hi <employee name=""> ,</employee></p><p>Your account has been granted access.</p><p>Use the credentials to access ServiceNow.</p><p>Regards,</p><p>Account Request Team</p>
But the resulting email is - <br> added for every paragraph break. Replacing the <p></p> with <br> doesn't help - the extra <br> is always inserted. Using div's does help but that's not a great way to style a message.
<html><body>
<br/><p>Hi <employee name=""> ,</employee></p>
<br/><p>Your account has been granted access.</p>
<br/><p>Use the credentials to access ServiceNow.</p>
<br/><p>Regards,</p>
<br/><p>Account Request Team</p>
<br/><div> </div><div style='display:inline'>Ref:EMCMG0488863</div></body></html>
Is there a workaround to this? Any properties to set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2014 02:20 PM
Hi,
You can do a workaround and clean up the <br/>'s with a before update business rule on sys_email.
current.body = current.body.replace(/(<br\s*\/?>)+/g, '');
Kind regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2014 04:21 PM
Hi All,
Hoping you might be able to help. We've started to use the email client to respond to inbound email's we've captured as records in the system.
Essentially for each inbound email received for a record I update a field called u_email_chain (in text form) and u_email_chain_html (in html form), so that when we load the email client, it displays the email chain of what has previously been sent.
I set up an Email Client template with the following code, but it still seems to display the HTML with all the additional spacing. The script on the body is as below:
<mail_script>
var rec = new GlideRecord("u_customer_enquiry");
rec.addQuery('sys_id', current.sys_id);
rec.query();
while (rec.next()){
var clean_body = rec.u_email_chain_html.replace(/<br\/>/g,'');
template.print("\n<hr>");
template.print(clean_body);
}
</mail_script>
What I'm finding is that the email client loads with the value of the u_email_chain_html field but with all the additional spacing. I did implement the business rule on the sys_email table as per Dan's suggestion, but this hasn't solved the issue when the email client loads.
Funnily enough, when a choose a quick message which also references the u_email_chain_html field, it adds the quick message and the email chain with all the correct spacing. (I'm guessing this is because this is considered an update, and the current.body = current.body.replace(/(<br\s*\/?>)+/g, ''); business rule runs). I did update the business rule to also be on 'insert' also, but no change.
Any ideas guys? Has anybody had much experience with Mail script on the email templates?
Thanks!
- Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2014 04:46 PM
Hi Scott,
I haven't read through the thread again. But just as a quick reply; try removing every rowbreak, even within your code.
Best regards,
Dan
Skickat fr?n min iPhone
17 sep 2014 kl. 01:22 skrev "Scott Lathlean" <community-no-reply@servicenow.com<mailto:community-no-reply@servicenow.com>>:
) <https://community.servicenow.com/?et=watches.email.thread>
Re: Quick Message HTML - ServiceNow inserting line breaks
svar fr?n Scott Lathlean<https://community.servicenow.com/people/Scott.Lathlean?et=watches.email.thread> i Support - Visa hela diskussionen<https://community.servicenow.com/message/724581?et=watches.email.thread#724581>