0

I am trying to add a custom object related list onto a tabbed visualforce page. every time i do it comes up with an error:

'Inspection__c' is not a valid child relationship name for entity Account

The code is below:

<apex:page standardController="Account" showHeader="true" 
      tabStyle="account" >
   <style>
      .activeTab {background-color: #236FBD; color:white; 
         background-image:none}
      .inactiveTab { background-color: lightgrey; color:black; 
         background-image:none}
   </style>
   <apex:tabPanel switchType="client" selectedTab="tabdetails" 
                  id="AccountTabPanel" tabClass="activeTab" 
                  inactiveTabClass="inactiveTab">   
      <apex:tab label="Details" name="AccDetails" id="tabdetails">
         <apex:detail relatedList="false" title="true" inlineEdit="true"/>
      </apex:tab>
      <apex:tab label="Contacts" name="Contacts" id="tabContact">
         <apex:relatedList subject="{!account}" list="contacts" />
      </apex:tab>
      <apex:tab label="Opportunities" name="Opportunities" 
                id="tabOpp">
         <apex:relatedList subject="{!account}" 
                           list="opportunities" />
      </apex:tab>
      <apex:tab label="Inspections" name="Inspection" 
                id="tabInsp">
         <apex:relatedList subject="{!account}" 
                           list="Inspection__c" />
      </apex:tab>
      <apex:tab label="Open Activities" name="OpenActivities" 
                id="tabOpenAct">
         <apex:relatedList subject="{!account}" 
                           list="OpenActivities" />
      </apex:tab>
      <apex:tab label="Notes and Attachments" 
                name="NotesAndAttachments" id="tabNoteAtt">
         <apex:relatedList subject="{!account}" 
                           list="CombinedAttachments" />
      </apex:tab>
   </apex:tabPanel>
</apex:page>

The custom object, Inspections, is 3/4 of the way down.

Thanks so much in advance.

1 Answer 1

3

When you use a relationship name in a query or in related list, you must use the relationship names without the __c. Instead, append an __r (underscore underscore r).

so it will be Inspections__r instead of Inspection__c

You can read more about relationship name in Salesforce reference guide

4
  • Unfortunately that doesn't work. i changed list="Inspection__r" /> but i still get the same error.
    – neo2049
    May 9, 2016 at 12:43
  • check relationship name, it can be Inspections__r as well because it depends on you what you have added while creating object
    – Himanshu
    May 9, 2016 at 12:58
  • Thanks. The child name is Inpections__r with an s at the end so all is working now.
    – neo2049
    May 9, 2016 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .