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
1111_forcecom1111_forcecom 

VisualForce Relation Objects

Hi,

 

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}"/>
        </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>


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.

 

 

Puja_mfsiPuja_mfsi

Hi,

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.

1111_forcecom1111_forcecom
Thank you so much, it works!!!

Regards

--
*Alejandra Helguero
*