+ Start a Discussion
Nkosilathi NcubeNkosilathi Ncube 

"not a valid child relationship name for entity Contact"

"not a valid child relationship name for entity", 
I have a custom object "Placement" which appears on the Contact Object as a related list, I keep geep getting the above error, I have gone into "Placement" and on the relationship and get the relationship name as "Placement1", I have tried to use the __r and even Placement1s__r, I still get "not a valid child relationship name for entity", Please Help
<apex:relatedList subject ={!Contact} list = "Placement1s__r />

 
Best Answer chosen by Nkosilathi Ncube
Nkosilathi NcubeNkosilathi Ncube
I used the schema builder and got the chield relationship name and added __r

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

please try below
<apex:page standardController="contact">
	<apex:relatedList list="Placemant1__r" />
</apex:page>

If you are using custom controller
<apex:page Controller="SampleCustom" tabStyle="contact">
    <apex:detail relatedList="false" title="true"/>
    <apex:relatedList subject="{!contact}" list="Placement1__r" />
</apex:page>

controller
 
public class SampleCustom
{
    contact cc;
     public contact getcc() {
        return cc;
    }
    
    public void setcc(SampleCustom__c sample ){
      this.cc  = cc ; 
    }
     public SampleCustom(){
         cc = [select id, name from contact where id = :ApexPages.currentPage().getParameters().get('id')];
     }
}

For Testing

  https://        //apex/PageName/?id=a0NS000000065Ec


Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya

 
Nkosilathi NcubeNkosilathi Ncube
Thanks Sandhya I have tried your solution and have even tried to pluralise the child object as others have suggested but to no avail, the relationship is a lookup relationship
SandhyaSandhya (Salesforce Developers) 
Hi,

Sorry if you have already checked below points, but still I suggest you to recheck.


Go to Setup > Create > your custom object, Application. Click on the custom field, the lookup that makes the link to contact. There you will find the real Child Relationship name, should be a plural form without the "__c". 

I recommend copy/pasting the relationship name, to make sure you've got it exactly right.


 Are you certain your relationship is correctly defined?
 If you go to a layout for the parent object, is there an option to add the related list for the child object there? (This will verify you have the relationship correct.)
 Are you certain you have the correct name for the relationship?

Please let me know if this helps you!

Thanks and Regards
Sandhya
Nkosilathi NcubeNkosilathi Ncube
Thanks I have checked if its a related list on the page layout and have checked the child relationship name which is on the right hand side, I will attach a screenshot later
Nkosilathi NcubeNkosilathi Ncube
User-added image
I have even used the schema builder to get Child Relationship name
Nkosilathi NcubeNkosilathi Ncube
I used the schema builder and got the chield relationship name and added __r
This was selected as the best answer