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
kickingboykickingboy 

Displaying related list data

Hi
I have 2 custom objects Service and Service Event which have a master-detail relationship. Child relationship name is ServiceEvents.
 
When I try to save the following code I get the error message: Error: Invalid field ServiceEvents for SObject Service__c
 
<apex:page standardController="Service__c">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are displaying Schedules from the {!service__c.name} Service record.
    </apex:pageBlock>
    <apex:pageBlock title="Schedules">
        <apex:dataTable value="{!service__c.ServiceEvents}" var="a" cellPadding="4" border="1">
              <apex:column>
               <apex:facet name="header">Name</apex:facet>
                {!a.Name}
              </apex:column>
        </apex:dataTable>
    </apex:pageBlock>
    
</apex:page>
 
This seems functionally  identical to the following code which works perfectly (it should its out of the VF manual). What am I not understanding?
 
<apex:page standardController="Account">
   <apex:pageBlock title="Hello {!$User.FirstName}!">
      You are viewing the {!account.name} account.
   </apex:pageBlock>
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!account.Contacts}" var="contact">
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>
 
JimRaeJimRae
There is a difference between your code and the sample.  You are using a datatable, and the sample uses a pageblocktable.  I had a similar code set implemented, and switched it to a datatable and it does not work.
So, would a pageblocktable work for your needs? If so, you should be set, if not, you will proabably need to implement a custom controller to extract the related list and reference it separately.
kickingboykickingboy
Hi Jim
I eventually managed to install Apex Explorer - as you suggested - which required the .Net framework (68MB download) and which itself required the 3.1 windows installer. The Explorer showed the name of the child realtionship name was ServiceEvents__r so when I added the __r suffix it worked but I did use a pageBlock
Stuart