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
WilliamShrewsburyWilliamShrewsbury 

Map key null not found in map

After some research this appears to be a bug in Spring '12 release.  Is anyone having issues with this and if so is there a work around that is applicable to this?  The full error is:

 

Map key null not found in map

Error is in expression '{!relatedContactMapId[timeCard.Contact__c].Id}' in component <apex:repeat> in page webex_training

 

So if I comment out the reference to in the VisualForce page I can get around the error but I am no longer pulling the needed information.  Any ideas would be appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Damien_Damien_

I wouldn't recommend doing it the way you are doing so currently.  By doing it this way, you are sort of defeating the purpose of the MVC architecture by putting the business logic into your view.  I'm not completely sure what is happening on the page, but it might be easier to use a wrapper class than to use a Map inside of your view.

 

All Answers

Damien_Damien_

I wouldn't recommend doing it the way you are doing so currently.  By doing it this way, you are sort of defeating the purpose of the MVC architecture by putting the business logic into your view.  I'm not completely sure what is happening on the page, but it might be easier to use a wrapper class than to use a Map inside of your view.

 

This was selected as the best answer
craigmhcraigmh

Something like this.

 

'{!if(timeCard.Contact__c=null,'',relatedContactMapId[timeCard.Contact__c].Id)}'

 

hemantgarghemantgarg

can we check the map contains key on vf page ?

Damien_Damien_

on the VF page, I think you might be able to do

{!map.get('someval') != null}

 Or at least some flavor of this.  I don't know the particulars off the top of my head.