2

Following the Visualforce example here, I can display the list of account names in a pageblocktable but changing the controller to Lead does not display the list of lead names. Why not? It works great with the Contact controller as well, but not the Lead controller.

According to this page, the Lead controller is also a type of standard list controller and it seems this simple thing should work. What am I missing?

Here's the complete source of the page:

<apex:page standardController="Lead" recordSetVar="leads" tabstyle="lead" sidebar="false">
   <apex:pageBlock >
    <apex:pageBlockTable value="{!leads}" var="ld">
      <apex:column value="{!ld.name}"/>
    </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>
  • 1
    Can you show us an example of your source code? – Michael Welburn Feb 1 '14 at 16:47
  • this might be an issue with object permission, pls check it... – Bforce Feb 1 '14 at 17:57
4

I took the Account example from your first link, and changed each Account reference to lead.

EDIT: From the doc page you link above, "This page does not specify a filter in the request, so the page is displayed with the last used filter." In my testing, my last used Lead filter happened to be "All Open Leads". If your last used filter shows no leads (e.g., "My Leads" if you don't own any leads), then the standard controller won't load any records by default. I've updated the code to show a List View dropdown for the standard controller using code from this doc page on using list views with standard controllers.

<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
  <apex:pageBlock >
    <apex:form >
      <apex:panelGrid columns="2">
        <apex:outputLabel value="View:"/>
        <apex:selectList value="{!filterId}" size="1">
          <apex:actionSupport event="onchange" rerender="list"/>
          <apex:selectOptions value="{!listviewoptions}"/>
        </apex:selectList>
      </apex:panelGrid>
      <apex:pageBlockTable value="{!accounts}" var="a" id="list">
        <apex:column value="{!a.name}"/>
      </apex:pageBlockTable>
    </apex:form>
  </apex:pageBlock>
</apex:page>

Note the use of apex:actionSupport to update the list in real time using the rerender param, and the addition of a matching id on the pageBlockTable for the rerender to reference.

  • Your code is identical to mine. There is no other code in the Visualforce page I'm working with. To be absolutely sure, I've copied your code and replaced my own with it but am seeing the same issue. What could be causing the issue? – SF1Dev Feb 1 '14 at 19:26
  • What is displayed? Can you post a screen shot? Also (silly as it sounds) - try in another browser? If you have development mode turned on (in-page editing of VF code), try turning it off temporarily. – Jason Clark Feb 1 '14 at 19:32
  • Initially I had only tested with Firefox 26. I've now tested with Chrome 32 as well with the same results. Here's a screenshot from Chrome of the custom page. I've disabled developer mode too. – SF1Dev Feb 1 '14 at 21:26
  • Curiouser and curiouser. Have you looked at a debug log? – Jason Clark Feb 1 '14 at 21:32
  • ok, now you've found me out. I'm still learning Salesforce as we're just getting started with it. How can I check the debug log for a visualforce page? Is it somewhere in the logs section of the developer console? – SF1Dev Feb 1 '14 at 21:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.