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
Rudi_HulsbosRudi_Hulsbos 

Map key null not found in map

Hi,

I am trying to display a map with map values in a visualforce page but keep getting Map key null not found in map error:

Controller:

public MAP<Quote,LIST<QuoteLineItem>> getQuotes(){
        quotelistmap = new MAP<Quote,LIST<QuoteLineItem>>();
         for(Quote getquotes : [SELECT Id, Name, Product__c, Product_Category__c, Total_Price_Incl__c,
                                                 (SELECT Id, Description FROM QuoteLineItems)
                                                  FROM Quote WHERE Opportunity.Link_to_Main_Opportunity__c = :o.Id]){
            quotelistmap.put(getquotes,getquotes.QuoteLineItems);
            system.debug('quotelistmap: '+quotelistmap);
        }
      return quotelistmap;
    }

Visualforce Page:

<apex:dataTable value="{!Quotes}" var="q">
    <apex:column value="{!q.Product_Category__c}"/>
    <apex:column value="{!q.Product__c}"/> 
    <apex:repeat value="{!Quotes[q]}" var="qli"> 
        <apex:column value="{!qli.Id}" /> 
    </apex:repeat>
</apex:dataTable>

Error Message:
Map key null not found in map
Error is in expression '{!Quotes[q]}' in component <apex:dataTable> in page quoteswithquotelineitems

I have searched the community and found some community members doing the exact same thing.

Please help?

Thanks,

Rudi
Neelanjan_SFDCNeelanjan_SFDC
I do not think you can work with any data types other than String or Integers in the key field in a Map.
It's better if you can convert the Key value to a String & then add to the map.

For more information:
http://force201.wordpress.com/2012/11/19/only-some-types-work-as-apex-map-keys-from-visualforce/