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
Ian GendreauIan Gendreau 

Reference Master Field Values from VF Page with Custom Object Controller

New to VF here...

I have a custom object named Materials__c.  It has a Master/Detail relationship with Opportunity, so any one Opportunity can have multiple Materials__c objects.  On my VF page, I can reference fields from Materials__c easily by using {!Materials__c.FieldName} because I'm using standardController="Materials__c".  Two questions:

1. How do I reference things on the Master object?  Like how do I reference Opportunity.Amount or Opportunity.Stage?
2. Taking it a step further, how do I reference fields from Objects the Master is related to? Like can I reference fields on the Account page of the Account that the Opportunity is tied to from a VF page that has a standarController of Materials__C?
 
pconpcon
  1. You'll have to query the parent object inside of your controller using SOQL and expose the parent as a variable
  2. Same as 1, you'll have to query them in your controller.
Let me know if you need more explaination or an example