Excessive HTML Spacing when using the Email Client (<p> </p>)

brnunn
Tera Contributor

Hi all,

I really am perplexed by this issue - maybe it's an HTML nuance I'm not familiar with.

When using (and only when using) the email client (notifications do not do this) within a SNow case, every time that SNow interprets a new line (< p>) it creates a ridiculous amount of white space between the paragraphs. I just want our users to be able to push enter and it creates a line break when sending an email from within the case. The HTML format has "paragraph" set as the default and every new line entered creates 2-3 lines of white space in the final result.

We are trying to plug in templates for copy/paste within SNow email client but it interprets the HTML in wonky ways. I can deal with doing some text editing before hand but...

for example: creating a bullet list puts it in a paragraph block, creates a paragraph line between each bullet item AND inserts this special character above the list < p> & nbsp;< /p>. A three item bullet point list is now taking up HALF the page in the final email.

Why does it generate < p> & nbsp;< /p> between special format sections? How do I stop this??

Any help would be so appreciated. (Added spaces in html chars so it would be visible)

Thanks in advance!!!!!!!!!

1 ACCEPTED SOLUTION

brnunn
Tera Contributor

Guys I opened a HI ticket and was provided a solution that I could tailor to work.


It's still a broken process but you can fix it by grabbing and deleting the extra carriage return tags with the following business rule. I haven't thoroughly tested it but in my first few trials it seems to work just fiiine. Was simpler than it seemed.



Business Rule: Fix Client Spacing


Table: sys_email


When: before
Update: true
Active:true


Script:
current.body = current.body.replace(/<br\/>/g,'');


View solution in original post

15 REPLIES 15

brnunn
Tera Contributor

Guys I opened a HI ticket and was provided a solution that I could tailor to work.


It's still a broken process but you can fix it by grabbing and deleting the extra carriage return tags with the following business rule. I haven't thoroughly tested it but in my first few trials it seems to work just fiiine. Was simpler than it seemed.



Business Rule: Fix Client Spacing


Table: sys_email


When: before
Update: true
Active:true


Script:
current.body = current.body.replace(/<br\/>/g,'');


Thanks for sharing your answer!


Another option is to keep your paragraphs closer to each other using CSS either by replacing all occurrences of <p> with <p style="margin: 0px; padding: 0px;"> using a business rule similar to one you mentioned or by inserting something like <style>p {margin: 0px; padding: 0px;}</style> into the HTML field as the default value.


Hi Bryan,


Thanks for sharing.


This worked for me but I also had to add the following condition:


current.type == 'send-ready'


and I had to modify the dictionary entry for sys_email.body to add the attribute "html_sanitize=false".


Erik Stolberg
Tera Guru

Posting for future search finds... I know it's not exactly the same as the original post, but it's similar enough.


I came across this issue (and post) as we've had issues with <br /> tags auto-translating into <p> </p> in the default 'text' field within Knowledge Articles (KB) upon save.



I found this seems to be a well-known issue with TinyMCE. Within HI, I was able to find 3 related articles:


PRB599780 / KB0538180


PRB584948 / KB0535106


PRB585174 / KB0524073



Excerpt from one Workaround:


Pressing return in a rich text editor like tinyMCE is supposed to create a paragraph break (in HTML, that's a <p>).


If you want to keep lines closer together (a single line-break, which is <br> in HTML), hold down the shift key when pressing return. This is standard across most word processors and email text editors.



I've found that directly editing the source HTML and wrapping my <br /> tags WITHIN the <p></p> tags solves this. It looks messy, but works...
<p>Text here <br /> & n b s p ;</p>


**you need the & n b s p ; otherwise the <br /> tag will be removed. Also, I had to space out the syntax to keep it from converting on the post here.