+ Start a Discussion
riffindusriffindus 

Stuck with Visual force child-parent relationship for standard list controller

Hi,

 

I am trying to get fields of parents into my child visual force page. i am missing something which thorws error to get the values from parent

 

<apex:page standardController="Job_Posting__c" recordSetVar="Job_Postings" tabstyle="Job_Application__c" sidebar="false">
<apex:pageBlock >
<apex:pageBlockTable value="{!Job_Postings}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.Position__c}"/>
<apex:column value="{!a.Position__c.Min_pay__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

Job_posting__c is the child of Poistion__c. min_pay__c is a field in Position object. first 2 fields are displaying correcty which is name name and position__c (there is also a custom field with the name position directly in child object)

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

When navigating through a Lookup or Master-Detail field, you need to change __c to __r

<apex:page standardController="Job_Posting__c" recordSetVar="Job_Postings" tabstyle="Job_Application__c" sidebar="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!Job_Postings}" var="a">
            <apex:column value="{!a.name}"/>
            <apex:column value="{!a.Position__c}"/>
            <apex:column value="{!a.Position__r.Min_pay__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 Regards

All Answers

SeAlVaSeAlVa

When navigating through a Lookup or Master-Detail field, you need to change __c to __r

<apex:page standardController="Job_Posting__c" recordSetVar="Job_Postings" tabstyle="Job_Application__c" sidebar="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!Job_Postings}" var="a">
            <apex:column value="{!a.name}"/>
            <apex:column value="{!a.Position__c}"/>
            <apex:column value="{!a.Position__r.Min_pay__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 Regards

This was selected as the best answer
riffindusriffindus

Thank you very much. it worked like charm.