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
Chris Weihe 2Chris Weihe 2 

Display Related List information from a Master Detail Relationship

I am trying to finish my Visual Force page with the presentation of Related List information.  I have the Standard Object (Account) and Custom Object (Account Document) in a Master Detail scenario as stated in Schema Builder:  Master-Detail Relationship from AccountDocument to Account.  The AccountDocument Related List is successfully displayed on my Account Page Layout.  
When I am on my VF Page I can successfully add the Related List for Contacts but when I go to add the Related List information for AccountDocument, I get error messages but no matter my approach.  One example of an error message:  Visualforce Error:  'AccountDocument__r' is not a valid child relationship name for entity Relationship.  Again, this is one example of a method I have used to try and get the information displayed.  Am I trying to display infomation that cannot be displayed?  
Thank you in advance for any insight that you could provide.
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

Hi Chris, I guess you might be going wrong with the child relationship name usually relationship names will be plurals eg:- 'AccountDocuments__r'.

Once go to the lookup field and check the childrelationship name.User-added image

Pradeep Kumar L.GPradeep Kumar L.G
Hey Chris

You should be using "Child Relationship Name" in <apex:relatedlist list=""/>
Ex: if your Child Relationship Name = AccountDocument then syntax is  “AccountDocument__r” I believe your relationship name is  “AccountDocuments” and you are missing "s".

Hope this helps

Thanks
Pradeep
 
Chris Weihe 2Chris Weihe 2
Thank you both for your responses, I did try that before, but I double checked because of your kind suggestions.  Unfortunately, I received the following message when launching the VF page via a Button on my Account Layout:  
Visualforce Error   'AccountDocuments__r' is not a valid child relationship name for entity Relationship.
Two additional clues:  On the custom object page, I am seeing the Relationship as Master-Detail.  As far as you know, should I still  be able to do this with Master-Detail Relationships? If so, any thoughts on why this would be not cooperating?  Thanks!!
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

Hi Chris, You can do it for Master-detail as well but it might not be plural for that how ever it's all depends on the relationship name you have given.

Coming to your point you said that you are calling VF page through button from Account layout ? is it via URL button or button over rided with visualforce page ? if it is URL button are seding Account Id as parameter value ?

Would you be able to post your code here it would be more helpful.

Chris Weihe 2Chris Weihe 2
I do not have anything in the VF Pager regarding Account ID due to the fact that some of the aspects fo the VF Page is working very well.  For example, when I select the Button i created on the Account Layout, the appropraite Account details were provided for Account.name & the approriate Contacts for the current Relationship were presented. I have the "Contacts" related list being referenced in the VF Page code below to demonstrate, I can succesfully get a Related List to display, a proof of concept, kind of thing.  


<apex:page sidebar="false" showHeader="false" standardController="Account" renderAs="pdf">
<img src="{!URLFOR($Resource.Logo)}" width="400px;"/>
   <apex:pageBlock title="Hello Valued Customer!">
      You are viewing a document status report for the following Relationship: <b> {!account.name}</b>
     <p> This information is current as of {!TODAY()}</p>
     <p> This report was produced by: {! $User.FirstName & ' ' & $User.LastName &",  "&  $User.Title }</p>

   </apex:pageBlock>

   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!account.Contacts}" var="contact">
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
 


</apex:page>

Thanks fagain for your help.