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
Jack InsJack Ins 

not a valid child relationship name for entity

Hello,

Been working on this too long and need some help.  I have a Master Detail relationship between Opportunity and a custom object.  I have added the Related list as I have added others to the VF Page but it is giving me the above error.  The code is very simple but I must be missing something.

Any help would be great.

Thanks Dwayne

 

<apex:outputPanel rendered="{!hasPolicy}" id="UpsellCampaignOppt">
	    <table style="width: 1100px;">
	    	<tr>
	    	<td colspan="1">
				<apex:pageBlock tabStyle="Campaign">
	    			<apex:pageBlockSection id="UpsellCO" title="Upsell Campaign Opportunities" collapsible="true" columns="1">
	    				<apex:relatedList list="Upsell_Campaign_Opportunities__r" subject="{!policy.Id}"/>
	   				</apex:pageBlockSection>
	   				<script>twistSection(document.getElementById("{!$Component.UpsellCO}").childNodes[0].childNodes[0]); </script>
	 			</apex:pageBlock>
			</td>
	 		</tr>
		</table>
	</apex:outputPanel>

 

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9
Do one thing go to your child object.
Locate the Lookup to opportunity field.
Click the Field name to open the detail.
There should be a field called "Child Relationship Name", we generally add "__r" to this name to render the related list/ or to do a parent to child query

All Answers

Avidev9Avidev9
I can see you are using a variable called policy.
Is this is instance of Opportunity ?
Jack InsJack Ins

Yes.  VF page is controlled by apex class the apex class is build based on Opportunity

public class PolicyDashboardController {

    public Opportunity policy{get;set;}

 I have other related lists that work with no problems are set up the same as this object.  The only difference is that this object halso has a master detail relationship to Campaigns too.

 

Here is code of my other related list:

<apex:outputPanel rendered="{!hasPolicy}" id="UndVerAlerts">
	    <table style="width: 1100px;">
	    	<tr>
	    	<td colspan="1">
				<apex:pageBlock >
	    			<apex:pageBlockSection id="UndwrVer" title="Underwriter Verifications/Alerts" collapsible="true" columns="1">
	    				<apex:relatedList title="" list="Underwriter_Verifications__r" subject="{!policy.id}" pageSize="5"/>
	   				</apex:pageBlockSection>
	   				<script>twistSection(document.getElementById("{!$Component.UndwrVer}").childNodes[0].childNodes[0]); </script>
	 			</apex:pageBlock>
			</td>
	 		</tr>
		</table>
	</apex:outputPanel>

 

Avidev9Avidev9
Do one thing go to your child object.
Locate the Lookup to opportunity field.
Click the Field name to open the detail.
There should be a field called "Child Relationship Name", we generally add "__r" to this name to render the related list/ or to do a parent to child query
This was selected as the best answer
Jack InsJack Ins

WOW Not thats interesting.  It worked for this. Why would it work for my other related object but differently for this one?

Avidev9Avidev9
You were just lucky!
Check the Child Relationship name shomehow they matched.
Jack InsJack Ins

LOL I like that answer and your right, i got lucky.  thanks for your help.