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
sfdc_beginner7sfdc_beginner7 

Is it possible to collapse related list on an object or limiting it to 1 or 2 records per related list ?

Is it possible to collapse related list on an object or limiting it to 1 or 2 records per related list ?
Best Answer chosen by sfdc_beginner7
Narender Singh(Nads)Narender Singh(Nads)
Hi,

The reason you are not able to see your VF page in drop down list of 'View' is because you are using list controller i.e. ApexPages.StandardSetController.
You will be able to see your VF page in the drop down list of 'List'.

If you want to Override 'View' with a page then you will have to use ApexPages.StandardController in the constructor of your extenstion controller.
Also, you will have to remove  recordsetVar="accList".

All Answers

Narender Singh(Nads)Narender Singh(Nads)
Hi,

No, it is not possible. 
You can vote for the idea here : https://success.salesforce.com/ideaView?id=08730000000BrKS


As a workaround what you can do is create a VF page containing your related list and put that VF page in page layout in a section.
Ajay K DubediAjay K Dubedi
Hi,

Always show more (or fewer) records per Related List in Salesforce Classic

Here's how to update your User preferences to increase or decrease the default number of records returned for a specific Related List in Salesforce Classic.

1. Select a Tab or Object
2. View a record for the object
3. Scroll to the bottom of the screen to find Always show me more/fewer records per related list
4. Click More to increase the default number of records per Related List or click Fewer to reduce the default number.

Note: The "more/fewer" link is different from the "show more" link that appears for Related Lists on the Record Detail page. "Show more" returns additional records as a one-time action and does not increase the default setting.

For More Details Refer to below link
https://help.salesforce.com/articleView?id=customizing_related_lists.htm&type=5

Thanks 
Ajay Dubedi
sfdc_beginner7sfdc_beginner7
I have written the below code for above funcationality using page block section
<apex:page standardController="account" recordsetVar="accList">
    <apex:pageBlock title="Detailed View">
        <apex:pageBlockSection title="{!Account.Name}" columns="1"> 
        <apex:detail relatedList="false"/>
        </apex:pageBlockSection>
        <apex:pageBlocksection title="Opportunities of Account">
        <apex:relatedList list="Opportunities"/> 
        </apex:pageBlocksection>
    </apex:pageBlock>
</apex:page>


now I want that whenever I click on account record it should open using this vf page.
i try to  edit the view 
setup>customize>account>link nutton action>view
but there i can't see my vf page 
I have written an apex class using page reference 
I am not sure where I am going wrong


Apex class:
public class getRecordId{
public String currentRecordId {get;set;}

    public getRecordId(ApexPages.StandardSetController controller) {
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
       
    }
}


VF page:
<apex:page standardController="account" recordsetVar="accList" extensions="getRecordId">
    <apex:pageBlock title="Detailed View">
        <apex:pageBlockSection title="{!account.Name}" columns="1"> 
        <apex:detail relatedList="false"/>
        </apex:pageBlockSection>
        <apex:pageBlocksection title="Opportunities of Account">
        <apex:relatedList list="Opportunities"/> 
        </apex:pageBlocksection>
    </apex:pageBlock>
</apex:page>
Narender Singh(Nads)Narender Singh(Nads)
Hi,

The reason you are not able to see your VF page in drop down list of 'View' is because you are using list controller i.e. ApexPages.StandardSetController.
You will be able to see your VF page in the drop down list of 'List'.

If you want to Override 'View' with a page then you will have to use ApexPages.StandardController in the constructor of your extenstion controller.
Also, you will have to remove  recordsetVar="accList".
This was selected as the best answer
sfdc_beginner7sfdc_beginner7
Thanks Narender ,Its working now also I have removed extension as I dont need it . This is my final vf page.
<apex:page standardController="Account" >
    <apex:pageBlock title="Detailed View">
        <apex:pageBlockSection title="{!account.Name}" columns="1"> 
        <apex:detail relatedList="false"/>
        </apex:pageBlockSection>
        <apex:pageBlocksection title="Opportunities of Account">
      <apex:relatedList list="Opportunities"/>
        </apex:pageBlocksection>
    </apex:pageBlock>
</apex:page>