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
icemft1976icemft1976 

is it possible to use apex:relatedList to display a Parent Object's related items?

I have a custom object (Letter_Of_Agreement) that has an Account record as it's master.

 

I was hoping to be able to leverage the existing related list mechanism to display the Account's contacts on a visualforce page (the page is using the LOA controller). 

 

 

Is it possible to reference the parent relationship of an object in a related list in some way?   i.e. <apex:relatedList list="Account__r.Contacts"  />

 

No matter the variation I use, I get an error "List attribute parent name 'account/account__r/etc' is an invalid field name for entity LOA"

 

 

Should I just recreate the related list functionality & look with a custom query and some visualforce?

Message Edited by icemft1976 on 03-03-2010 07:17 AM
Best Answer chosen by Admin (Salesforce Developers) 
Rajesh ShahRajesh Shah

Check the subject attribute of the relatedList tag. Using that, you would be able to achieve what you want. Heres an example where I display the Contacts related list of Account from Opportunities standard controller

 

<apex:page standardController="Opportunity"> <apex:detail relatedList="false"/> <apex:relatedList list="Contacts" subject="{!Opportunity.AccountId}"/> </apex:page>

 

 

 

All Answers

Rajesh ShahRajesh Shah

Check the subject attribute of the relatedList tag. Using that, you would be able to achieve what you want. Heres an example where I display the Contacts related list of Account from Opportunities standard controller

 

<apex:page standardController="Opportunity"> <apex:detail relatedList="false"/> <apex:relatedList list="Contacts" subject="{!Opportunity.AccountId}"/> </apex:page>

 

 

 

This was selected as the best answer
icemft1976icemft1976

Rajesh,

 

thank you very much for pointing out what should have been obvious!  I thought I had checked the Standard Component docs already.

 

Next time I will 'look with my eyes and not my mouth.'  Or keyboard, in this case. :)

 

AJ

 

 

symantecAPsymantecAP

I have created a VF page. It has 3 fields. Prodcut Name , Product Family, Product description.

PRODUCT NAME is a lookup field to an object PRODUCT INFORMATION.

whenever Product Name is chosen it should auto populate Product Family and Product Description

symantecAPsymantecAP

 Here is my code

 

 

<apex:page standardController="SMART_Program__c" Extensions="SMARTProgramParticipatingSKUs" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Define Participating Products for Program: {!SMART_Program__c.Name}" columns="2">
            
                <apex:outputField value="{!SMART_Program__c.Program_Start_Date__c}"/>
                <apex:outputField value="{!SMART_Program__c.LastModifiedDate}"/>
                <apex:outputField value="{!SMART_Program__c.Program_End_Date__c}"/>
                <apex:outputField value="{!SMART_Program__c.Desired_Forecasted_Revenue__c}"/>
                <apex:commandButton style="align:center" action="{!back}" value="Back to Program"/>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection >
                <apex:commandButton action="{!addrow}" value="Add Row"/>
                <apex:pageBlockTable value="{!productList}" var="product">
                    <apex:column headerValue="SKU Description">
                    <apex:inputField value="{!product.SKU_Description__c}"/>
                    </apex:column>
                    <apex:column headerValue="Product Family">
                    <apex:outputField value="{!product.Product_Family__c}"/>
                    </apex:column>
                   
                </apex:pageBlockTable>
            </apex:pageBlockSection>  
        </apex:pageBlock>
    
     </apex:form>
  </apex:page>