+ Start a Discussion

VisualForce Relation Objects



My name is Alejandra, i have a problem with display info in a table. The thing is:


I have two objects a) Contact (Salesforce object) and b) Beneficio (Custom object,  I personalize this object)

Both are relation directly, and this information can display in actually Contact Layout, i try change the format can display this information


I try to display all Beneficios have one contact whit this code


<apex:page standardController="Contact">
  <apex:pageBlock title="Contacts">
    <apex:pageBlockTable value="{!contact.Beneficio__c}" var="beneficio">

        <apex:column value="{!beneficio.proposito__c}"/>

This is the error,

Error: Invalid field Beneficio for SObject Contact


I must be use other name or object name or alias? Please help me.





The relationship name is always end with '__r' not '__c'.

First you need to check the "Child Relationship Name" and then put in Vf page like:if Child Relationship Name is "Beneficio" then you need to add __r after the name as:

<apex:pageBlockTable value="{!contact.Beneficio__r}" var="beneficio">


How to check "Child Relationship Name" :

go to your child object.And click on the field which refer to the contact ,there is a information about "Child Relationship Name"  then put this name with __r in VF



Please let me know if u have any problem on same and if this post helps u plz give KUDOS by click on star at left.

Thank you so much, it works!!!


*Alejandra Helguero