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

can we use len???

Can we use len() in VisualForce...

If yes anyone have an example cause I keep getting:

 Error: Incorrect parameter for function len(). Expected Text, received Number


The following works for me:

<apex:page > <apex:outputText value="{!LEN($User.LastName)}"/> </apex:page>


From the error, it sounds like you are passing the wrong data type into the LEN function.  LEN only works on strings, not numbers, currency, dates, etc.  If I try to use it with an opportunity amount, which is not a string, but currency, like so



<apex:page standardController="opportunity"> <apex:outputText value="{!LEN(opportunity.amount)}"/> </apex:page>


I get the same error.  Wrap it in the TEXT function, though:



<apex:page standardController="opportunity"> <apex:outputText value="{!LEN(TEXT(opportunity.amount))}"/> </apex:page>


and  I get the output I expect.