addError() when used in apex classes escapes HTML even if escaped optional var = FALSE
Last updated 2022-02-10 ·Reference W-2533146 ·Reported By 61 users
Summary
addError() with HTML characters doesn't take care of escape parameter when used in apex classes.
Repro
1. Create an apex class,
===========
public class TestMessageController{
public Account test{get;set;}
public TestMessageController(){
test = new Account();
test.Id.addError('Correct');
test.Name.addError('im an html error with a <a href="http://google.com">link</a>', FALSE);
}
}
==============
2. Create VF page,
==============
<apex:page controller="TestMessageController">
<apex:messages />
<apex:form >
<apex:outputLabel value="Test String" /><apex:inputField value="{!test.Name}" id="test"/>
<br/><apex:message for="test"/>
</apex:form>
</apex:page>
===============
3. Preview the VF page and you can see the HTML content.
Workaround
Implementing this via apex trigger should work.
FYI, https://success.salesforce.com/issues_view?id=a1p30000000T4PjAAK.
Reported By (61)





































Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.