You need to sign in to do that
Don't have an account?
Ruslan
Unable to get records of a related object
I have a custom object Deal__c and a standard object Contact. The I created a custom lookup field Contact in the Deal__c object (related to Contact object). Then I went to Deal__c page layout and added Contact to Selected Relationship Fields.
At this point I would like to display all contacts that are related to a particular Deal.
<apex:page standardController="Deal__c">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are viewing the {!Deal__c.name} deal.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:pageBlockTable value="{!Deal__c.Contact}" var="contact">
<apex:column value="{!contact.Name}"/>
<apex:column value="{!contact.MailingCity}"/>
<apex:column value="{!contact.Phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are viewing the {!Deal__c.name} deal.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:pageBlockTable value="{!Deal__c.Contact}" var="contact">
<apex:column value="{!contact.Name}"/>
<apex:column value="{!contact.MailingCity}"/>
<apex:column value="{!contact.Phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
As a result I get an error message:
Error: Invalid field Contact for SObject Deal__c |
If I change {!Deal__c.Contact} to {!Deal__c.Contact__c} then I get a different error message:
Error: Unknown property 'String.Name' |
Where am I going wrong here?
Appreciate any suggestions
All Answers