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
Brian12345Brian12345 

How to limit the # of characers displayed in an outputField?

I have a requirement to limit the # of characters displayed in an outputfield.  If the field value is > 100 characters, the displayed text should be truncated.  As shown below, I tried to use 'left' to limit the characters to 100, but I recieve the following error:

 

"Error occured trying to load the template for preview: value for outputField is not a dynamic binding!. Please try editing your markup to correct the problem."

 

Can I accomplish this in VF without using a controller? 

 

<apex:outputField value="{left(!cx.match_criteria__r.searcher__r.account.Investment_Focus__c,100)}" />  

 

Message Edited by Brian12345 on 05-12-2009 01:34 PM
Message Edited by Brian12345 on 05-12-2009 01:35 PM
Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

so this is what i tried and it's working

 

 

<apex:page standardController="account"> <apex:outputText value="{!LEFT(account.name,12)}"></apex:outputText> </apex:page>

 

 looks like you don't need outputField , can you use outputText?

 

All Answers

Ron HessRon Hess

i think you can, change the {! location like this:

 

 

<apex:outputField value="{!left(cx.match_criteria__r.searcher__r.account.Investment_Focus__c,100)}" />

 

 

 

Brian12345Brian12345

Thanks Ron! 

 

I am recieving the following syntax error, but only when using the code you provided:

 

Error

Error: Syntax error. Missing ')' 

 

What do you make of this? 

 

Thanks,

 

B.T. 

Ron HessRon Hess

so this is what i tried and it's working

 

 

<apex:page standardController="account"> <apex:outputText value="{!LEFT(account.name,12)}"></apex:outputText> </apex:page>

 

 looks like you don't need outputField , can you use outputText?

 

This was selected as the best answer
Brian12345Brian12345

Thanks Ron!

 

I don't understand why it should make a difference...but when I changed from <apex:outputField> to <apex:outputText> I no longer recieved the error.

 

Can you help me (us) understand why?

 

 

Ron HessRon Hess

output field is a much more complex tag, it will bind it's value to a very specific field of an sobject.

 

output text is simpler, and will bind to the output of an expression or field value.

 

 

crop1645crop1645

It is worth noting that the message: "value for outputField is not a dynamic binding!" can occur:

 

  • When you don't use an ! immediately after the left curly bracket '{'.  In your example, the ! should appear before the 'l' in the function 'left'.
  • <apex:outputField value="{left(!cx.match_criteria__r.searcher__r.account.Investment_Focus__c,100)}" />

     

  • If you forget to include a closing '}' such as in this expression (no '}' after the final paren and before final double quote):
  • <apex:outputField value="{left(!cx.match_criteria__r.searcher__r.account.Investment_Focus__c,100)"

     

deepak_programmerdeepak_programmer

value for outputField is not a dynamic binding! 

 

Possible reason: missing {! ............. } braces for the expression.

 

<apex:pageblocktable id="table1" value="{!lstMyLiveIOs}" var="obj" >                  
          <apex:column headerValue="Booked Quantity">

                 <apex:outputField value="obj.FB_Quantity__c" />
          </apex:column>
</apex:pageblocktable>

 

Correct syntax is:

<apex:outputField value="{!obj.FB_Quantity__c}" />