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
GerhardNewman2GerhardNewman2 

Visualforce relatedlist error - not a valid child relationship name

I am having trouble with one related list.
 
Code:
<apex:relatedlist list="affiliateClients__r" rendered="{!isAffiliate}"/>
<apex:relatedlist list="AffiliateOpportunities__r" rendered="{!isAffiliate}"/>
<apex:relatedlist list="contacts"/>
<apex:relatedlist list="clipfactorypo__r"/>
<apex:relatedlist list="openactivities"/>
<apex:relatedlist list="activityhistories"/>
<apex:relatedlist list="opportunities" rendered="{!isAffiliate}"/>

 The clipfactorypo__r related list gives an error.  I can't spot what I am doing wrong here.  I have successfully got the other related lists working, and I don't see what is so special about this one.  These are all child relationships off the Account object.  I have checked the name using apex explorer by looking in the Child Relationships branch of the Account object.
The only difference between AffiliateOpportunities__r and clipfactorypo__r as far as I can see is that the first is a related list to a standard object, and the second is to a custom object.
jwetzlerjwetzler
Can you go into the defintion and make sure that you've explicitly specified the Child Relationship Name?  I recall hearing about a bug regarding child relationships not defaulting their names.
GerhardNewman2GerhardNewman2
Yes on the custom object, the customer Lookup field has been defined as....
Related To: Account
Child Relationship Name: clipfactorypo
 
jwetzlerjwetzler
Unfortunately the relationship is not visible if it's not on the page layout.  Maybe that's your problem?
GerhardNewman2GerhardNewman2
Yes that was the problem!  Thanks.  :smileyhappy:  Maybe that error message can be fixed?  Its a bit misleading as there was nothing wrong with the name I was using.....
dkraundkraun
Hi,

I am having this same problem.  I am trying to display the Histories related list for a custom object.  I have checked and everything checks out with the child relationship name in the Apex Explorer.  When you say that adding the list to the page layout fixed this, what page layout are you referring to?  I do display the related list in the default salesforce page layout for my custom object, but I am working with a custom visualforce page, and that is where the error is being thrown.  Is there some page layout for custom pages?

-David
GerhardNewman2GerhardNewman2

Hi David,

I was using an extended controller, and using the detail section as the starting point for my page.  My guess is that standard controller picks up which related lists are available by looking at the associated page layout(s).  There might be a better answer to your problem, but I would try using an extended controller and adding your custom controller code to it; then any related list you have associated on the custom objects page layout should be available.

Cheers,

Gerhard