0

Hi friends i unable to fetch records in visualforce page using standard controller.I'm trying to fetch accounts.when i use below code.It display's only 2 records.

<apex:page standardController="Account" recordSetVar="accounts" 
                              tabstyle="account" sidebar="false">
<apex:pageBlock >
    <apex:pageBlockTable value="{!accounts}" var="a">
        <apex:column value="{!a.name}"/>
     </apex:pageBlockTable>
 </apex:pageBlock>
</apex:page>

But when i try with other object like opportunity.It doesn't display any records.What are the reasons for this problem.I tried so many ways to investigate i didn't found any issues

  • Where are you using this page? We need more context. – Adrian Larson Sep 12 '16 at 14:51
  • Are you testing as some user who has access to only few records – sfdc Sep 12 '16 at 14:52
  • I'm trying on my developer console and I'm the admin in this organisation. @sfdc – Pavan tej Sep 12 '16 at 14:54
  • I have a feeling this may be an x-y problem. Try asking about what you're trying to do, instead of asking about a specific way to try and do something. There's probably a way you can achieve the same effect as what you're looking for, but this approach likely won't work. – Adrian Larson Sep 12 '16 at 14:54
  • I had created a visualforce page for testing.But,the same code is working properly in other org.But, what are reasons to happen for this problem.@Adrian Larson – Pavan tej Sep 12 '16 at 14:55
3

The reason for this behavior is that the page is displaying the accounts based on the last filter you've used. To fix this, try accessing the Account tab and then click on All Accounts in the View.

After that try your VF page. You should see all accounts.

This is documented in this article - "Accessing Data with List Controllers"

From the article

This page does not specify a filter in the request, so the page is displayed with the last used filter.

  • Really surprising @Anil – Pavan tej Sep 12 '16 at 15:27

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.