2

I have a LongText field that I'm about to change to a rich text to take advantage of some formatting, but when I got to switch it Salesforce asks if there's any HTML in it that I'm using in Visualforce pages.

Well, there is, but it's being rendered as text along with everything else in HTML emails.

I have a custom component that uses an Apex class to pull the field out (the field is on a product but the email is being sent via an approval on a quote) and it renders any html in there as just normal text.

If I convert the field to Rich text, I still get the HTML rendered, just more of it!

The component looks like this:

  <apex:component controller="ShippingHelper" access="global">
    <p>Email email email</p>
    <p>{!SupportEmailBody}</p>
    <p>Email email email</p>
    <p>Etc</p>
  </apex>
1

For any string field (Text, LongText, RichText), you can always use apex:outputText with escape="false" to display any HTML in the field as HTML. Note you can't display HTML in string fields via apex:outputField.

Example:

<apex:outputText value="{!myStringField}" escape="false"/>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.