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
Anupama PandeyAnupama Pandey 

Apex Related List - list attribute do not support custom object

I am trying to display the list of custom object sample__c having lookup relationship with Account using standerd controller (Account) . I am unable to pull them up. i also wrote extension to pull the related samples
<apex:page standardController="Account" extensions="QuickyExtensionController"> 
   <style>
   .activeTab {background-color: lightblue; color:white; 
         background-image:none}
   .inactiveTab { background-color: lightgrey; color:black; 
         background-image:none}
   </style>
    <apex:pageBlock title="Hello {!$User.FirstName}!" > 
        <p>You are viewing the {!account.name} account.</p>
            <apex:tabPanel activeTabClass="activeTab" inactiveTabClass="inactiveTab">
                <apex:tab disabled="false" label="Quicky"> 
                   <apex:relatedList  list ="quickyList" >
                  </apex:tab> 
            </apex:tabPanel>
    </apex:pageBlock> 
</apex:page>

My controller code goes here  

public class QuickyExtensionController {
  List<Account> quickyList { get; set;} 
    public QuickyExtensionController(ApexPages.StandardController controller) {
              //populate the list on page load 
            quickyList = [Select Quicky__c from Account where Id = : ApexPages.currentPage().getParameters().get('id')];
}

}

Error I received is 

Visualforce Error
Help for this Page

'quickyList' is not a valid child relationship name for entity Account
Quicky has lookup relationship to Account -  Please advice, If I am missing anything ! much appreciated
Mani RenusMani Renus
In Vf you have to give like this below..

<apex:relatedList  list ="quickyLists__r" >

Hope it helps!!
Deepak Kumar ShyoranDeepak Kumar Shyoran
You need to pass the relationship Name in the attribute list like.. list="ChildRelationShipName"

Example : As we know that there is parent-child relationship between Account and Contact and we we want to show Contact related list as displayed in Native Account page to display all associated Contact record for a Account then we have to pass the Child relation ship name in following way
You can find this name from Child Object fields by clicking on the field which link Parent Object
<apex:page standardcontroller="Account"  >
	<apex:relatedList list="Contacts" />
</apex:page>

Please mark my answer as a best solution to your question to help others if it solves your problem.
Virendra ChouhanVirendra Chouhan
Hi Anupama Pandey,

If you want to display only related list then you dont need to write Extension.
Just correct your code with remove extension from page  and use object relationship name in relatedList tag.
i.e.

<apex:page standardController="Account">
 <style>
   .activeTab {background-color: lightblue; color:white; 
         background-image:none}
   .inactiveTab { background-color: lightgrey; color:black; 
         background-image:none}
   </style>
    <apex:pageBlock title="Hello {!$User.FirstName}!" > 
        <p>You are viewing the {!account.name} account.</p>
            <apex:tabPanel activeTabClass="activeTab" inactiveTabClass="inactiveTab">
                <apex:tab disabled="false" label="Quicky"> 
                   <apex:relatedList list="object_sample__r" />
                  </apex:tab> 
            </apex:tabPanel>
    </apex:pageBlock>

Kind regards
Virendra

Anupama PandeyAnupama Pandey
1. Approach 1 : when I pulled the related to controller extension, I do not receive any data back (quickyList__r) results in  (See picture 1)
<apex:relatedList list="quickyList__r" />

Where quickyList - is populated through extension as shown 

public class QuickyExtensionController {
  List<Account> quickyList { get; set;}
    public QuickyExtensionController(ApexPages.StandardController controller) {
              //populate the list on page load
            quickyList = [Select Quicky__c from Account where Id = : ApexPages.currentPage().getParameters().get('id')];
}

}

User-added image



2. Approach two - just adding the relationship name - 'Do not work' 

3. Approach three - removing controller extension and replacing quicky with Quicky__c failes even  (See picture 2)

User-added image
Virendra ChouhanVirendra Chouhan
Hi Anupama Pandey,

Now i am 100% sure your childrelationship name is not correct.
please check this
  1. Go to Setup->Create->Objects (Or Setup->Customize)
  2. Click on the field of the *Child* Object in the relationship
  3. Click on the Parent relationship 
  4. Take a look at the "Child Relationship Name"
  5. If it's a managed package field, add namespace__ before it
  6. If it's a custom relationship, then add the __r after it.

User-added image


In this case the Child Relationship name is Line_Items.
So, I use Line_Items__r.

Check this in your object.

Kind regards
Virendra 
Mani RenusMani Renus
You missing 's'(quickyList__r) in your first approach..

You should use this..

<apex:relatedList  list ="quickyLists__r" >