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
baller4life7baller4life7 

Amount, Date cannot be displayed formatted with Map

<apex:repeat value="{!params}" var="param">
<apex:dataTable value="{!map[param]}" var="opp" width="100%" align="left">
<apex:column >
 <apex:outputText value="{0, number, $#,###.00}"> <apex:param value="{!opp.Amount}" /> </apex:outputText>
</apex:column>
</apex:dataTable>
</apex:repeat>

 

ErrorError: The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice.

 

Does anybody know why the amount cannot be displayed formatted? {!map} is a Map<String, List<Opportunity>>

It doesn't work for a date, too.

 

 

Maybe it's because a map cannot remember datatypes so every field of the opportunity is a String if you access it in Visualforce?!?

baller4life7baller4life7

Ok, but the formatting still doesn't work...

 

<apex:column value="{0, number, $#,###.00}" >
      <apex:param value="{!opp.Amount}" /> 
</apex:column>

 The code above generates the following error message:

 

ErrorError: Formula expression is required for attribute value in <apex:column>
Ankit AroraAnkit Arora

Try this :

 

<apex:column value="{!opp.Amount}" />

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

baller4life7baller4life7

Ankit, thank you for your help, but my problem is the formatting. I want to format the amount!

If I use your solution, I cannot format the amount. Is there a solution where I am able to format the amount?

Greg RohmanGreg Rohman

I'm experiencing a similar issue when attempting to format a map value. My VF code is as follows:

 

<apex:outputText value="{0,number,$###,###}"><apex:param value="{!expenseTotals['2008']}"/></apex:outputText>
// SIMPLIFIED CONTROLLER

public Map<String,Decimal> getExpenseTotals() { 
Map<String,Decimal> annExpenseTot = new Map<String,Decimal>();
annExpenseTot.put('2008',12345.67);
return annExpenseTot;
}

 The error in the IDE is 

 

The value attribute on <apex:outputText> is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice.

 

 

Please advise as to a solution, as this appears to be a bug.

 

-Greg

baller4life7baller4life7

The only thing that works for me so far is writing a wrapper class with string fields... But obviously I don't want to write a wrapper class all the time... Can I report that bug to the Salesforce.com support team directly?

Guy Bickel 1Guy Bickel 1
I know this is a really old post, but I was having a similar problem.  You can get a decimal formatted as a currency if you nest a outputText inside of the column:
<apex:column headerValue="Moola">
  <apex:outputText value="{0, number, $###,###.00}">
    <apex:param value="{!myMoneyField}"/>
  </apex:outputText>                                
</apex:column>

Hope this helps anyone else searching for this solution...