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
alexaalexa 

How to truncate a textarea field

Hello!  I'm new to Salesforce Development.  I've been asked to display only the first 250 characters of a field.

 

If I try

 

 <apex:outputField value="{!LEFT(item.Description,250)}" />

 

I get the error
Incorrect parameter for function LEFT(). Expected Text, received Object

 

If I try

 

  <apex:outputText value="{!LEFT(item.Description,250)}" />

 

I don't get any errors but all of my whitespace is gone, rendering the field unreadable.  

 

item.Description is a textarea.  

 

Any advice is appreciated.  Thanks!

Cool_DevloperCool_Devloper

Hi Alexa,

 

Try using s style attribute with either of these and see if you fix the length using that.

 

I think that should work!

 

Cool_D

kenfkenf

You can also use the attribute escape="false" in your outputText element.

 

--k