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
Rick SF AdminRick SF Admin 

Display Master-Details Value as a Name instead of ID# on Visual Force Page (PDF)

I created for a custom object (Demo__c) with a button that will render the record as a Visualforce Page PDF. I have a Master-Detail field in the Demo object that lookup the standard Account object. When I added the following code {!Demo__c.Account__c} and generated the PDF, it shows up in the PDF as the Account ID opposed to the Name displayed on the object. See PDF Example below: 

PDF Example: "We are proud to announce that we now have a partnership with {!Demo__c.Account__c} (01214141421241b <--should display the Account name) for 3 years."

How can I have it display Account name AND the respective Account's BillingAddress?  
Best Answer chosen by Rick SF Admin
srlawr uksrlawr uk
Try 
 
{!Demo__c.Account__r.Name}

first

but.. as the RenderAs=PDF can be a bit weird sometimes, as a backup solution, try creating a formula field on Demo__c that then holds the value

Account__r.Name

and that will "hold" the Account Name as a local field to the demo object.

All Answers

srlawr uksrlawr uk
Try 
 
{!Demo__c.Account__r.Name}

first

but.. as the RenderAs=PDF can be a bit weird sometimes, as a backup solution, try creating a formula field on Demo__c that then holds the value

Account__r.Name

and that will "hold" the Account Name as a local field to the demo object.
This was selected as the best answer
srlawr uksrlawr uk
You can do BillingAddress the same way, yep. Note Addresses are complex composite fields though with wierd sub fields,

so it'll be like

Account__r.BillingState
Account__r.BillingStreet

etc.etc.

and we are all at a loss at how to best format them when some address lines might be blank.. sometimes that is easier in a formula field!
Rick SF AdminRick SF Admin
I went the formula field route and just hid the fields on the object. This works just fine.Thanks again.