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
pooja biswaspooja biswas 

recordVarSet issue

Hi
I have a requirement as follows
In Account List View Page, I have added a custom button (fetch_Names) which will fetch all account names followed with contact details and opportunity details.
I have written the code for this.
<apex:page standardController="Account"
           recordSetVar="accounts"
           tabStyle="Account"
           sidebar="false">
 
 <apex:pageBlock >
          <apex:repeat value="{!accounts}" var="a">
          
<apex:pageBlockSection title="{!a.name}">

</apex:pageBlockSection>

  <apex:relatedList list="Contacts" subject="{!a.Id}"/>
  
<apex:relatedList list="Opportunities" subject="{!a.Id}" />

</apex:repeat>      
     </apex:pageBlock>
         
</apex:page>
Its working in the sense it displays only a few accounts but not all the accounts.
so I miss out on many account with related contacts.

How to to make sure it display all the accounts names?

thanks
pooja
 
Mahesh DMahesh D
Hi Pooja,

Basically how it works is based on the user's latest view opened.

Go to Accounts tab and select the view 'All Accounts' like below:

User-added image

Now you can execute your code, it will display all accounts.

The reason behind this is, 

This page does not specify a filter in the request, so the page is displayed with the last used filter. For information on using filters with list controllers, see Using List Views with Standard List Controllers.

For more information, please go through the below links:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_access_data.htm


Please do let me know if it helps you.

Regards,
Mahesh
pooja biswaspooja biswas
Hi Mahesh
Thanks for ur reply like wise let me be clear with a screen shot

sorry I was not clear with previous post.
I do not have any custom button, the LIST button of account is overriden with my visual force page.

List Button of Account

Now I did exaclty as per ur post but its not showing all records only a few.
I created many accounts today but they are not reflecting.
Am I missing on something?

Thanks
pooja
pooja biswaspooja biswas
Hi mahesh
It does not display all the records as per ur post.
The solution is to have an extension class and call SetPageSize.
public with sharing class MyExtension
 {
    public MyExtension(ApexPages.StandardSetController controller)
    {
       controller.setPageSize(1000);
    }
}

<apex:page standardController="Account"
                    recordSetVar="accounts"
                    tabStyle="Account"
                    sidebar="false"
                    extensions="MyExtension">
 
 <apex:pageBlock >
          <apex:repeat value="{!accounts}" var="a">
          
<apex:pageBlockSection title="{!a.name}">

<apex:relatedList list="Contacts" subject="{!a.Id}"/>
  
<apex:relatedList list="Opportunities" subject="{!a.Id}" />

</apex:pageBlockSection>

</apex:repeat>      
     </apex:pageBlock>
 
</apex:page>