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
john hejohn he 

Default value BR() of the Text Area Field is converted to _BR_ENCODED_ by Apex:inputField

I am developing the visualforce page for user to edit the record.  but I found that the BR() is converted to _BR_ENCODED_, which is absolutely not what I want.

 

here is the example to mimic the issue:

 

1. create a object  let's say MyObject

2. add one field "short description" type = Text Area

3. set the default value for the field as following:

a. Monday

        b. Sunday

        c. Saturday

    the formalu is like this: "a. Monday" & BR() & "b. Sunday" & BR() & "c. Saturday"

 

if you check the short description field on the salesforce standard page, it looks good.

 

but if you create a VF page to edit this field:

<apex:page standardController="MyObject__c">
<apex:form >
<apex:pageblock >
<apex:pageblockSection >
<apex:pageblockSectionItem >
<apex:outputLabel value="{!$ObjectType.MyObject__c.Fields.short_description__c.Label}"/>
<apex:inputField value="{!MyObject__c.short_description__c}"/>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>

 

the BR() is converted into _BR_ENCODED_ and the whole default string is: 

a. Monday_BR_ENCODED_b. Sunday_BR_ENCODED_c. Saturday

 

terrible!

 

Could anyone help in this?  thanks!

 

John He

Navatar_DbSupNavatar_DbSup

Hi,

You are right. So in this you can use apex:inputTextarea  and bind the value through the controller as per your need .

 

Try the below code as reference (Pass the MyObject Record ID as URL);

 

 

<apex:page standardController="MyObject__c">

<apex:form >

<apex:pageblock >

<apex:pageblockSection >

<apex:pageblockSectionItem >

<apex:outputLabel value="{!$ObjectType.MyObject__c.Fields.short_description__c.Label}"/>

<apex:inputTextarea value="{!MyObject__c.short_description__c}" />

</apex:pageblockSectionItem>

</apex:pageblockSection>

</apex:pageblock>

</apex:form>

</apex:page>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

john hejohn he

Hi Navatar,

     thank you for your reply!

     It is still an issue.

 

     Let's try this scenario:  using the VF page to override the standard New Button.  then if we use InputField, the default value will be "a. Monday_BR_ENCODED_b. Sunday_BR_ENCODED_c. Saturday".  If we change it to InputText area, when creating a new record, it will be blank....

 

     any suggestion?

 

     thanks!

 

john He

DikshantDikshant

Hello, did anyone get a solution to this problem? 

Daniel Camp 15Daniel Camp 15
Yes, where is an answer?  Anyone?

BR()
returns in a text field as
_BR_ENCODED_

When you use BR() in a formula for a Task record in a Flow or an EmailSend Body, it returns _BR_ENCODED_ and doesn't create a line break.  Since line breaks don't work in a text template in fields or a formula, how can you create a text field that will populate data from variables into a field?