0

I have a parent custom object called Game__c and a child custom object called Player__c.).

The child Player__c has 4 fields: Name(String), Phone__c(Number), isHealthy__c(boolean), and Game__c(lookup).

im trying to create a Visualforce page presented in each Game record the related child records arranged in a table(fields in table are name,phone,isHealthy). i have problem with access to the records of child.

code

 <apex:page standardController="Game__c">
     <apex:pageBlock title="Hello!">
       You are viewing the {!Game__c.name} Game.
      </apex:pageBlock>
      <apex:pageBlock title="Players">
       <apex:pageBlockTable value="{!Game__c.Player__c}" var="p">
          <apex:column value="{!p.Name}"/>
          <apex:column value="{!p.phone__c}"/>
          <apex:column value="{!p.isHealthy__c}"/>
       </apex:pageBlockTable>
     </apex:pageBlock>
</apex:page>

1 Answer 1

1

To access a custom child relationship, you need to use __r suffix instead of __c.

<apex:pageBlockTable value="{!Game__c.Player__r}" var="p">

You can read more about this syntax in one of my older answers.

You must log in to answer this question.

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