Rendering HTML from a textarea properly

Hi,

I’m building a skuid page to display cases (we use email-to-cases), and I’m having difficulty displaying emails.

When I use “textbody” for an email, it displays the text as a long string and not rich text formatting. When I use HTMLbody, it displays the HTML code. I would either like to display the RTF properly, or display the HTML in the email.

I suspect there is a way to do this with running a snippet in the Field Renderer, but I’ve tried multiple ways to do this and I’m not having luck. Please advise.

Thanks!

Hi Shane, Should the user be able to edit the email body? If not you could use a template field, “allow html” and display the HTMLbody in the template field. Afaik the template should render the html body correctly. Cheers

I tried this and the HTML is not rendering. It is just showing the raw code.

Ok, after doing a little more research I’m seeing that even though I “allow HTML”, it won’t pick up the HTML in {{HTMLbody}}. It only picks up HTML in the “Template” box that I type myself.

Is there a workaround? I even tried wrapping:

{{HTMLbody}}

but it doesn’t work.

Shane,

I’m having this exact issue. Did you come up with a solution?

I wanted to display the output of html generated by a Salesforce email template. I used the jQuery replace html function. If you implement this, it would need to be maintained as its dependent on exact html values and DOM hierarchy which skuid could change at any time.

Steps:

1. Create a rich text field for display
2. Note the unique DOM id
3. Create a snippet like below


$ = skuid&#46;$;<br />var emailTemplateModel = skuid&#46;model&#46;getModel('PreferredEmailTemplate');<br />var firstRow = emailTemplateModel&#46;getFirstRow();<br />var htmlValueRaw = firstRow&#46;HtmlValue;<br />$("#uniqueDOMId &gt; div:first-child")&#46;replaceWith(htmlValueRaw); 


EDIT:

To reduce the risk of having my jQuery being invalidated by changes, I ended up

  1. Creating a wrapper and using its Id in the jQuery selector
  2. Putting a template in the wrapper (you could still do a rich text field if you want)
  3. Performing the replaceWith function on that template.

I ran into fewer issues using this method.