I'm trying to do something fairly simple, display a value from a Map<String, Decimal>. When I do, though, I get the following error message:

Unknown property 'BigDecimal.test'
Error is in expression '{!SUMQTYCost['test']}' in component <apex:page> in page testpage
Error evaluating dynamic reference 'test'

The tag which causes this error is {!SUMQTYCost['test']}, regardless of where it appears in the page, whether it's in the value attribute of an apex:OutputText tag or just in the text of the page.

SUMQTYCost is declared as:

public map<string, decimal> SUMQTYCost { get; set; } //Map of CostCenter (api name) to total cost for that CostCenter

I have a method which populates SUMQTYCost which is called toward the beginning of the controller's constructor. For testing purposes, I added the following code to the end of that method:

SUMQTYCost.put('test', 9999);

The debug log shows {Analytical=0.00, Disposal=0.00, Permits & Fees=0.00, Rental Equipment=0.00, Subcontractor=0.00, test=9999}.

When I try to open the VF page, The error message indicates it's trying to pull the value from BigDecimal.test which clearly doesn't exist. If I change the quoted value in the page 'test' to 'somethingElse', the error changes to BigDecimal.somethingElse. This happens even if I DON'T update the quoted value in the controller. This rules out anything related to the map not containing the key.

When I first encountered this, I was trying to use {!SUMQTYCost[i]} (i is the var for a pageBlockTable that parents this. The error would show for BigDecimal.Analytical. 'Analytical' happens to be the value of the first element in the list I'm iterating through.

Is there a way to get it to treat this as a Map<String, Decimal> rather than trying to dynamically call non-existent properties on some other kind of random datatype?

2 Answers 2


I tried to recreate the scenario.


<apex:page controller="AwSnap">
    <apex:form >
            <apex:outputText value="{!SUMQTYCost['test']}"/>

Controller :

public class AwSnap {

    public Map<String, Decimal> SUMQTYCost { get;set;}

    public AwSnap(){
        if(SUMQTYCost == null){
            SUMQTYCost = new Map<String, Decimal>();
            SUMQTYCost.put('test', 9999);

And I can see the value in VFPage.

enter image description here

I dont see an issue here. The only way it would not work is if your map does not contain your key. So make sure you use a combination of apex:repeat tags on iterating on keys first and then figure our the value from the map in another apex repeat. Something like this : https://salesforce.stackexchange.com/a/232477/45062


I figured it out. The page I'm working on calls a VF component which has

<apex:variable var="SUMQTYCost" value="{!<calculated value of Decimal type>}" />

Apparently, and I didn't know this, a variable inside of a component is scoped to include any pages that the component is used on.

Morel of the story, be careful not to create variable which matches the name of a property on the controller or extension and be especially careful with variable names in components.

(The troubleshooting to discover this involved renaming the property in the controller and the page and noting that the error message when updating the VF page in Salesforce still referenced the old name. Ctrl+F for the old name turned up no matches, so I started checking unrelated components in the page and found a component which used a variable on the page with the same name.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .