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
ashish.agarwalashish.agarwal 

Reference fields of Master Object in a VisualForce Page

Hi,

 

I have created a custom object called "Procedures" which is having Master-Detail relationship with standard object "Contact"

 

I am trying to create a VisualForce page to print a PDF report on "Procedures". In this PDF, I need to display the Name & Address of the "Contact"

 

How do I reference the fields of the master object "Contact" ? I tried the following but it is not working.

 

<apex:OutputField value="{!Procedures__c.Contact__r.Name}"/>

 

Any pointers will be highly appreciated.

 

Thanks & Regards,

Best Answer chosen by Admin (Salesforce Developers) 
ashish.agarwalashish.agarwal

Hi,

 

I was able to resolve the problem. I was not referencing it using the correct name. The field that I created was "Patient's Name" and hence it should be referenced as 

 

<apex:OutputField value="{!Procedures__c.Patient_s_Name__r.Name}"/>

 

Anyways, thanks Prasanna for taking out time to look into this and respond.

 

Regards,

All Answers

_Prasu__Prasu_

Are you using the standard controller for this? You will need to write extension and make query for values of those fields.

 

--Prasanna

ashish.agarwalashish.agarwal

Hi,

 

I was able to resolve the problem. I was not referencing it using the correct name. The field that I created was "Patient's Name" and hence it should be referenced as 

 

<apex:OutputField value="{!Procedures__c.Patient_s_Name__r.Name}"/>

 

Anyways, thanks Prasanna for taking out time to look into this and respond.

 

Regards,

This was selected as the best answer