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
ab79ab79 

Visualforce - Page layouts

Do Visualforce pages that use a standard controller have access to page layout metadata?  If so how?  To give an example, here's a simple Account page:

 

<apex:page standardController="Account" showHeader="true" tabStyle="account">

<apex:detail relatedList="false" title="true"/>

<apex:relatedList subject="{!account}" list="Contacts" />

<apex:relatedList subject="{!account}" list="Opportunities" />

<apex:relatedList subject="{!account}" list="OpenActivities" />

<apex:relatedList subject="{!account}" list="NotesAndAttachments" />

</apex:page>

 

The apex:page component will only show fields that are in the page layout, so that works fine.  However the related lists always show up.  Say one of these related lists are not added to the normal Account page layout, is there any way that the Visualforce page could be aware of that?  Thanks for your help.

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

If you set relatedlist='true' in the apex:detail component then remove the apex:relatedlist components you will get the related list as defined in the layout, which seems to be what you are asking for....

 

All Answers

pat!pat!

From what I have experienced, you define what related lists that will show in your visualforce page. It doesn't matter if its added or not in the standard page layout. I believe you are the one that must be aware of the relationships your objects have.

You can see all the child relationships and their respective relationship name in the salesforce.schema in a Force.com project created in eclipse. And from that information, you define which related lists to be displayed in your visualforce page like in your example.

I'm still not sure if I get what you really intend to do so correct me if I misunderstand your question :)

 

Best Regards,

Pat

aballardaballard

If you set relatedlist='true' in the apex:detail component then remove the apex:relatedlist components you will get the related list as defined in the layout, which seems to be what you are asking for....

 

This was selected as the best answer
ab79ab79

Thanks, that worked.