0

Hi on my VF page I want to render output panal on the based of if the key exist or not. I wan to check if the key exist or not. While checking I am getting an error that

Map key result__c not found in map

My code to check the key and render the output panel

   <apex:repeat value="{!visitFieldNames}" var="vfld">
      <apex:variable var="vfldDesc" value="{!visitFieldDescMap[vfld]}" />
            <apex:outputPanel rendered="{!if(visitRecord[vfld] != null, true, false)}">
                 <option value="{!visitRecord[vfld]}" selected="selected">{!visitRecord[vfld]}</option>
            </apex:outputPanel>

Why I am getting error I also tried by using

    rendered="{!if(visitRecord != null, true, false)}"

But still I am getting the same error. Please guide me how can I achieve it.

  • 3
    In the past it wasn't possible to check - see can we check if a key exists in a map in vf page. So unless this has changed in the last year or so you will have to do the work in the controller. – Keith C Dec 3 '14 at 9:25
  • The "containsKey()" method in the controller is the only way I could think! Alternatively you can try with the following: "You can build a delimited string with all the keys of the map in controller and then you use SF formula CONTAINS(delimited_string_with_map_keys, key)" as mentioned in salesforce.stackexchange.com/questions/15748/…. – Vignex Dec 3 '14 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.