function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Including HTML in Text Formulas? HTMLENCODE Doesn't Work.

Is there any way to including HTML in our text formulas?  We tried to use HTMLENCODE, but we get the following error message:


"Error: Function HTMLENCODE may not be used in this type of formula"


Ideally, we could bold text and add image links based on the status of other fields, but can't figure out how to do it.





You can put HTML tags as normal, but in lots of places it will get escaped back out so that you still see the brackets instead of the formatting.


One way around that is to use the apex:outputText component with escape equal to false, though I know that might always be ideal:

<apex:outputText escape="false" value="{!Object__c.Field__c}" />



There are specific formula functions for LINK and IMAGE, however.



As an aside, HTMLENCODE makes your code HTML-printable, which means that you definitely wouldn't be able to do bold and images and such. However, you may also take a look at the IMAGE and HYPERLINK formula operators, but that won't let you do colors, change fonts, or anything else that's fancy. If you're using Visualforce, the method posted above is the correct method. If you're hoping to do that in a report or standard page, there are some limited options available; take a look at Help & Training under Formula Operators.