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
Kent ManningKent Manning 

Determining the related list name for use in Visualforce

When using the <apex:relatedList subject="{!xyz__c}" list="???"/ > tag in visualforce, how or where do I determine the name (spelling) of the related list that that needs to be inserted in the list="???" parameter ? 

 

For example:

 

<apex:relatedList subject="{!xyz__c} list="OpenActivities"/> displays the Open Activity related list, but I only found out the name must be spelled as "OpenActivities" by looking in the Force.com Cookbook. I had tried a number of other spelling before I found this.

How do I determine what the name and spelling needs to be?

 

Thanks in advance.

 

 

JimRaeJimRae

The Eclipse Schema Browser an the Apex Explorer are great tools to help with this.

What you do is navigate (in either tool) to the object you are looking to add the related list for, expand it, look for a node called "child relationships" and expand that.

expand the child node you are looking for and you will see something called "Relationship Name", that is what you need.

Kent ManningKent Manning

Thanks Jim! 

 

This worked (somewhat).  I was able to use the schema in the Apex Explorer as you suggested, to get the Relationship Name.  I was then able to get some related lists to show up, but others would not.  For example:

 

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

 

allows me to see the Activity History and Open Activities without any problems, but if I say list="Tasks" or list="Histories" I get the following errors:

 


'Tasks' is not a valid child relationship name for entity Demo/Install Report


'Histories' is not a valid child relationship name for entity Demo/Install Report

 

even though the schema shows these as child relationships. 

 

Am I missing something here?  Do you have any idea why some work and other do not?  

JimRaeJimRae

I have read in other posts on the boards here that these are special related lists, and behave differently.

No real good explaination was ever provided.

Glad you are getting closer.

Kent ManningKent Manning
I appreciate the help.  I'll keep looking....:smileyhappy:
slaljislalji

I am trying to find the right value for the list in the related list tag for the Product2 standard controller.  The related list is the pricebook entry list for a prduct detail page.  My code is below:  

 

<apex:page standardController="Product2">
<apex:sectionHeader title="Product" subtitle="{!Product2.name}"/>

<apex:pageBlock >
<apex:pageBlockSection title="Product Detail">
<apex:outputField value="{!product2.name}"/>
<apex:outputField value="{!product2.family}"/>
<apex:outputField value="{!product2.ProductCode}"/>
<apex:outputField value="{!product2.description}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:relatedList title="Price Books" id="PricebookEntries" list="pricebookentries"/>

</apex:pageBlock>

</apex:page>

 

I then override the "VIew" page in the products buttons and links with this visualforce page.  I click on a product and then I recieve an error:

 

'pricebookentries' is not a valid child relationship name for entity Product

I used Apex Explorer to find out the child relationships of product2 and the relationship name is "PricebookEntries".  This is not working for me.

 

Can any of you help?