You need to sign in to do that
Don't have an account?
Referencing Fields from Object in Master-Detail Relationship
Hello,
I have created a custom object CustomObject__c that is a detail of Account in a Master-Detail relationship. I am developing a VisualForce page with the standard controller for the object CustomObject__c. So, I can show in the page the fields from this object, like {!CustomObject__c.name}. When I type {!CustomObject__c.Account__c} what is shown in the page is a link for the corresponding account in the relationship field. But I want to show fields from this Account, like account.name, account.phone, account.website. It doesn´t work if I try {!CustomObject__c.Account__c.name} and I still haven´t found a way of defining a controller extension for doing this. Can anyone help?
Thanks
What you need to do is to use the relationship name for the field. You can find this in a couple of ways:
1. Run a describeObject on the custom object
2. Go to Setup | Administration Setup | Create | Objects and click on the custom object. The click on the name of the Master Detail field. You will then see a field called "Child Relationship Name" field. This will be the name of the relationship (simply add "__r" to the relationship).
So in your example, if the custom object Master Detail field "Child Relationship Name" is "Account", then you would use:
{!CustomObject__c.Account__r.Name}
To show the name field.
Jay
Thanks a lot, that's what I wanted.