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
RelaxItsJustCodeRelaxItsJustCode 

Need a VF guru..... Help with VF related list.... Will give Kudos.

 

This is the basic page I''m testing with.  Below is the VF page code.  How do I change the order of all of the related list that appear under the detail section of the on the object?

 

Thank you, Steve ps I will give Kudos for you if you solve my question

<apex:page standardController="Contact" 
extensions="sampleDetailPageCon">
//<style>
//.fewerMore { display: none;}
//</style>
<apex:form > 
    <apex:pageMessages /> 
    <apex:detail relatedList="true"></apex:detail>
<apex:pageblock id="CustomList" title="Related Opportunities"  >
    <apex:pageBlockTable value="{!oppz}" var="o" rendered="{!NOT(ISNULL(oppz))}">
     
      
       <apex:column>
             <apex:commandLink action="/{!o.id}" value="{!o.Name}" />
       </apex:column>
        
        <apex:column value="{!o.Name}"/>        
        <apex:column value="{!o.Account.Name}"/>        
        <apex:column value="{!o.Type}"/>
        <apex:column value="{!o.Amount}"></apex:column>       
        <apex:column value="{!o.CloseDate}"/>
     </apex:pageBlockTable>
     <apex:outputLabel value="No records to display" rendered="{!(ISNULL(oppz))}" styleClass="noRowsHeader"></apex:outputLabel>
    </apex:pageblock>
</apex:form>
</apex:page>

Here is the apex to go wit

public class sampleDetailPageCon {    
    private List<Opportunity> oppz;    
    private Contact cntact;     
    public sampleDetailPageCon(ApexPages.StandardController controller) {        
        this.cntact= (Contact)controller.getRecord();    
        }    
        public List<Opportunity> getOppz()    
        {        
            Contact con = [Select id, Account.id FROM Contact where id = :cntact.id];        
            if (con.Account == null)         
                return null;        
                oppz = [Select id, Name, Account.Name, CloseDate, Amount, Type from Opportunity where Account.id = :con.Account.id];        
                return oppz;    
        }
}




Best Answer chosen by Admin (Salesforce Developers) 
izayizay

Since you are using the <apex:detail/> tag you can rearrange the related lists from the page layout editor.

 

if you want your custom list to show above any of the original related list you have to to set the relatedList attibute of the apex:detail tag to false and add the related lists to the vfpage ueing the apex:relatedList tag

 

Example code:

 

<apex:detail title="true" inlineEdit="true" showChatter="true" relatedList="false" oncomplete="location.reload();">
    <apex:form id="theForm">
        <c:detailcalendar myObject="{!Call_Report__c.Id}"/>
    </apex:form>
    <apex:relatedList list="OpenActivities"/>
    <apex:relatedList list="ActivityHistories"/>
    <c:GenericHistoryComponent myObject="{!Call_Report__c}" recordLimit="15"></c:GenericHistoryComponent>
    <apex:relatedList id="noteslist" list="NotesAndAttachments" />
</apex:detail>

 

 

Hope this helps!

All Answers

Sonu Sharma.ax1610Sonu Sharma.ax1610

Hi,

 

There are two ways by which you can display the records in your defined order in related list.

 

1:) Change the 

oppz = [Select id, Name, Account.Name, CloseDate, Amount, Type from Opportunity where Account.id = :con.Account.id];     

to

oppz = [Select id, Name, Account.Name, CloseDate, Amount, Type from Opportunity where Account.id = :con.Account.id order by Name ASC]; 

 2:) Use a wrapper class that will store all opportunity data in the order in which you insert in the list using any custom logic.

 

I hope this will answer your query.

 

-S

RelaxItsJustCodeRelaxItsJustCode

No sorry I didn't mean the order of the data in the related list I mean like on a opportuntiy screen you have the detail area between the 2 edit buttongs....

 

Then below that related list from open activities, activity history, opportunity product (line items.... etc...  How do I take a VF page with a custom VF related list and organize the page so that my vf list appears in the top down order I chose....  Any ideas?

 

Thank you,

Steve

izayizay

Since you are using the <apex:detail/> tag you can rearrange the related lists from the page layout editor.

 

if you want your custom list to show above any of the original related list you have to to set the relatedList attibute of the apex:detail tag to false and add the related lists to the vfpage ueing the apex:relatedList tag

 

Example code:

 

<apex:detail title="true" inlineEdit="true" showChatter="true" relatedList="false" oncomplete="location.reload();">
    <apex:form id="theForm">
        <c:detailcalendar myObject="{!Call_Report__c.Id}"/>
    </apex:form>
    <apex:relatedList list="OpenActivities"/>
    <apex:relatedList list="ActivityHistories"/>
    <c:GenericHistoryComponent myObject="{!Call_Report__c}" recordLimit="15"></c:GenericHistoryComponent>
    <apex:relatedList id="noteslist" list="NotesAndAttachments" />
</apex:detail>

 

 

Hope this helps!

This was selected as the best answer
RelaxItsJustCodeRelaxItsJustCode
I am no stranger to the page layouts in salesforce but the problem is that this visualforce related list doesn't show up on the page layout screen either not under related list not under visual force... what do you think I can do to fix this?
izayizay

Look at updated post above!!! I've added sample code.