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
Bob_zBob_z 

Visualforce page lookup field back to standard object

I have a visualforce page using a standard account object. I also have a child custom object Bids_Sent__c. There is an account lookup field on the related child object titled "Awarded__c".   In my visualforce page i want to some how reference a field Service_Agreement_Verbiage__c on the Bids_Sent__c object. The child relationship name for Bids_Sent__c lookup field "Awarded__c" is "Bids_Sent4". Below I tried this mapping on my VF page and I get the following error.
Error: Unknown property 'VisualforceArrayList.Service_Agreement_Verbiage__c'

{!Account.Bids_Sent4__r.Service_Agreement_Verbiage__c}
Shivam Yadav 8Shivam Yadav 8
Hi Bob,

Please refer below code :

<apex:page standardController="account" recordSetVar="accounts" tabstyle="account" sidebar="false">
<apex:pageBlock >
<apex:form >
<apex:dataList value="{!accounts}" var="a">
<apex:pageblocksection title="Contacts for account {!a.name}" >
<apex:repeat value="{!a.contacts}" var="c">
<apex:inputField label="Contact name" value="{!c.name}"/><br/>
</apex:repeat></apex:pageblocksection> </apex:dataList>
</apex:form>
</apex:pageBlock>
</apex:page>

Thanks
AmarpreetAmarpreet
Hi Bob,

Use below Code instead of using "{!Account.Bids_Sent4__r.Service_Agreement_Verbiage__c}" in your VF as "Account.Bids_Sent4__r" is Array/List:

 <apex:repeat value="{!Account.Bids_Sent4__r}" var="bids">
   {!bids.Service_Agreement_Verbiage__c}
</apex:repeat> 
Bob_zBob_z
Hi Amarpreet,

I don't want to use a repeater, I just want it to show up once on the VF page
AmarpreetAmarpreet
Hi Bob,

"{!Account.Bids_Sent4__r}" will always return a Collection (Array/List). So, you need to iterate the List to access the elements of that List. After that, you can fetch the value of the field for each element (i.e. record) one by one.

In your case, an Account can have multiple records of "Bids_Sent__c",then how will you decide that which record of "Bids_Sent__c" will be displayed on your VF.

Also, If you want to fetch only first record, then you can use: " {!account.Bids_Sent4__r[0].Service_Agreement_Verbiage__c}" in your VF. For this, you need "extension" of Standard Controller.