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
vijay kumar 300vijay kumar 300 

Standard Controller not fetching the Data

Hi,

I have created a simple visualforce page with a standard controller, but it's not fetching the data from the Account object.please help me.Below is my code snippet.
<apex:page standardController="Account" recordSetVar="Account">
 <apex:form >
  <apex:pageBlock title="All Accounts">
   <apex:pageBlockTable value="{!Account}" var="a">
    <apex:column value="{!a.Name}"/>
    <apex:column value="{!a.AccountNumber}"/>
   </apex:pageBlockTable>
  </apex:pageBlock>
 </apex:form>
</apex:page>

any help would be appreciated
 
Best Answer chosen by vijay kumar 300
NagendraNagendra (Salesforce Developers) 
Hi Vijay,

Absolutely there is no issue with the code.Please find the explanation below:

Reason:If you get into the accounts tab and check the view which is selected for accounts,it should be something like 
  • Recently viewed accounts
  • New this week
  • New last week
  • Platinum and gold SLA customers
When you are loading the visual force page any of the above option should have been selected on the accounts tab,so the reason its not displaying any account records.

Solution:Just get into accounts tab and select the view type as 
  • All Accounts
Now come to the visual force page and refresh the page, the standard controller now will display the list of account object records.

I have checked this in my developer org and its working pretty fine.

Kindly mark this as the best solution if it helps you.

Best Regards,
Nagendra.P

 

All Answers

Ajinkya1225Ajinkya1225
Hi Vijay,
You are almost there! Just a small change in your code should suffice! Here is the code-
 
<apex:page standardController="Account" recordSetVar="accounts">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accounts}" var="a" >
                <apex:column value="{!a.Id}"/>
                <apex:column value="{!a.name}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Please upvote and mark this answer as solved, if it helped you.
Cheers!
Ajinkya Deshmukh
vijay kumar 300vijay kumar 300
Hi Ajinkya1225,

I have tried with your code, but i am still facing the same problem.


Thanks,
Vijay.
NagendraNagendra (Salesforce Developers) 
Hi Vijay,

Absolutely there is no issue with the code.Please find the explanation below:

Reason:If you get into the accounts tab and check the view which is selected for accounts,it should be something like 
  • Recently viewed accounts
  • New this week
  • New last week
  • Platinum and gold SLA customers
When you are loading the visual force page any of the above option should have been selected on the accounts tab,so the reason its not displaying any account records.

Solution:Just get into accounts tab and select the view type as 
  • All Accounts
Now come to the visual force page and refresh the page, the standard controller now will display the list of account object records.

I have checked this in my developer org and its working pretty fine.

Kindly mark this as the best solution if it helps you.

Best Regards,
Nagendra.P

 
This was selected as the best answer
vijay kumar 300vijay kumar 300
Hi Nagendra.P

Thank you so much for your help its working fine.
Muthukumar ChinnachamyMuthukumar Chinnachamy
Hi Nagendra,

Thank you, the same problem came across and resolved. However, it is showing only limited records, do anyone knows why?