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
SmytaSmyta 

How to display multilevel relationship objects in visualforce?

Hello,

 I want to display child of a child for Account standard object. How to achieve this in Visualforce?
 If I use standard controller "Account" it gives an error.
 May be this is a very basic question but I am new to Visualforce.Thanks in Advance.

Smita
Best Answer chosen by Smyta
Mahesh DMahesh D
Hi Smita,

Is there any namespace for the object.

If possible, can you paste the Object configuration and the relationship screens here.

Regards,
Mahesh

All Answers

Mahesh DMahesh D
Hi Smita,

Please paste your existing VF page so that it will easy to troubleshoot on it. Also explain more about what error you are getting.

Regards,
Mahesh
SmytaSmyta
Hi Mahesh,

Following is the code snippet,
<apex:page standardController="Account">
    <apex:detail relatedList="false"/>
    <apex:relatedList list="Payments"/>
  </apex:page>

Error is
'Payments' is not a valid child relationship name for entity Account 

 Actually my question is wrong.."Payment" is the direct child of "Account" object and the child relationship name 'Payments' is also correct.
Not sure what is wrong here.

Regards,
​Smita
Mahesh DMahesh D
Hi Smita,

Below is the solution for your issue:
 
<apex:page standardController="Account">
    <apex:detail relatedList="false"/>
    <apex:relatedList list="Payments__r"/>
</apex:page>

I also tested in my DE environment and below is the results.

User-added image

Please do let me if it helps you.

Regards,
Mahesh
SmytaSmyta
Hi Mahesh,

I have already tried that, it gives the same error : 
'Payments__r' is not a valid child relationship name for entity Account

Here "Payment" is not any custom object but it has been installed from a package which was available to integrate with the other system.

Regards,
Smita
Mahesh DMahesh D
Hi Smita,

Is there any namespace for the object.

If possible, can you paste the Object configuration and the relationship screens here.

Regards,
Mahesh
This was selected as the best answer
SmytaSmyta
Hi Mahesh,

Yes there is a namespace for the object lets say "abc" and 'Payment' object is realted to 'Account' via Lookup relationship.

I tried using
<apex:page standardController="Account">
<apex:detail relatedList="false"/>
<apex:relatedList list="abc__Payments__r"/>
</apex:page>

in visualforce but no luck.

Thanks for your help.
--Smita
 
Mahesh DMahesh D
Hi Smita,

Here I would like to know few things:

(1) How are you testing this VF page?

(2) If you are passing the Account Id, is it having Payment child records.

(3) When you are running the VF page, what error you are getting.

(4) If possible Pintscreens.


Regards,
Mahesh
SmytaSmyta
Hi Mahesh,

Using namespace like below is working now I don't what was the issue when I tried before. 
<apex:relatedList list="abc__Payments__r"/>

Thank you so much for all your help.

Regards,
Smita
Mahesh DMahesh D
Hi Smita,

Glad that your issue got resolved with name space :-)

Please martk it as resolved so that it will be helpful to others.

Regards,
Mahesh