0

I have a long list of "related lists" available to me that I can put on a Contact layout. I would like to display these same related lists on a visualforce page using <apex:relatedList> and the Contact standard controller...however, I'm not able to do this because they are not lookup fields, and I cannot find the child relationship names.

Does that mean that I'm not able to use them with <apex:relatedList>?

  • 1
    Can you give an example of one of these related lists you are unable to display? – Christian Carter Feb 2 '16 at 18:53
  • One of them relates to a custom object "Proposal__c". Another is a field on "Property__c", "Primary_Contact__c"--looks like Property(Primary Contact). Another is "Notes & Attachments". None of these are from Lookup fields, but they are all available as related lists. – MRG Feb 2 '16 at 18:58
  • I do not know if you'll be able to get Notes & Attachments, but you should definitely be able to get the other relationships. Both Lookup and Master Detail relationships can be shown with apex:relatedList, and you can get the relationship name from them by looking at the field detail. – Christian Carter Feb 2 '16 at 19:00
  • Is something wrong with my visualforce then? <apex:page standardController="Contact" showHeader="false" sidebar="false" > <apex:relatedList list="Proposals" /> </apex:page> – MRG Feb 2 '16 at 19:11
  • Content cannot be displayed: 'Proposals' is not a valid child relationship name for entity Contact – MRG Feb 2 '16 at 19:12
0

I found the solution here: VF Page to Show Related Lists from Lookup Object on my Main Object

The problem was that I needed to add an __r to the end of the "child relationship name". New Apex: PROPOSAL

<apex:relatedList title="" subject="{!Contact}" list="Proposals__r" />

PROPERTY(PRIMARY CONTACT)

<apex:relatedList title="" subject="{!Contact}" list="Properties1__r" />
  • that is already mentioned in many documents :) – Himanshu Feb 2 '16 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.