0

I have the following objects:

Object: A

  • Picklist: I
  • Field: 1
  • Field: 2
  • Field: 3

Object: B (This is where I want the visualforce page (table)

Current visualforce page that works in Object B:

<apex:page StandardController="B__c" showHeader="false" sidebar="false">
<apex:pageBlock title="Numbers">
    <apex:pageBlockSection >
        <apex:outputField value="{! B__c.1__c }"/>
        <apex:outputField value="{! B__c.3__c }"/>
        <apex:outputField value="{! B__c.2__c }"/>
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

Trying to update it so that I can pull the numbers from the related object. Also trying to change it to a table type. The reason why is because I have a picklist in Object A that I would like to use in the table so I know what numbers belong to what item in the picklist.

<apex:page StandardController="B__c" showHeader="false" sidebar="false">
<apex:pageBlock title="A Fields">
    <apex:pageBlockSection >
        <apex:outputField value="{! A__r.I__c }"/>
        <apex:outputField value="{! A__r.1__c }"/>
        <apex:outputField value="{! A__r.2__c }"/>
        <apex:outputField value="{! A__r.3__c }"/>
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

this obviously does not work. How can I solve this?

1 Answer 1

2

You can access parent objects fields like this.

<apex:page StandardController="B__c" showHeader="false" sidebar="false">
<apex:pageBlock title="A Fields">
    <apex:pageBlockSection >
        <apex:outputField value="{! B__c.A__r.I__c }"/>
        <apex:outputField value="{! B__c.A__r.1__c }"/>
        <apex:outputField value="{! B__c.A__r.2__c }"/>
        <apex:outputField value="{! B__c.A__r.3__c }"/>
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

Even for standard objects, it works in a similar way.

{!contact.account.name}
2
  • I tried that before and it doesn't work. I get an error message "Error: Unknown property ...".
    – user56320
    Jun 12, 2019 at 18:16
  • 1
    Sorry. I had a typo. it does work.
    – user56320
    Jun 12, 2019 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy