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
BRBR 

Using apex:relatedList inside apex:repeat

Hi,

 

In our VF page we are writing like this

<apex:repeat ........
<apex:relatedList subject = ..........
</apex:repeat .....

Inside "subject" of related list we are passing some id which we are getting from "repeat" . On display the first "repeat" is showing correct related list as it should according to the id passed, but from the next line its showing the old relatedlist again and again on every repeat. Though next time different id is being passed .

 

Any suggestions are welcome. Thanx in advance

bob_buzzardbob_buzzard

Most odd.  I have something similar that iterates a list of accounts and displays the opportunities as related lists, and the appropriate opportunities for each account get displayed.

 

Mine can be reduced down to:

 

 

<apex:page standardController="Account" recordSetVar="records" id="thePage">
<apex:repeat value="{!records}" var="record">
   <apex:relatedList subject="{!record.id}" list="Opportunities"/>
</apex:repeat>
</apex:page>

 How does this compare with yours?

 

BRBR

 

Mine is almost same
<!--
<apex:repeat value="{!Install_Base__c.osstom__Service_Bases__r}" var="sb">
        <apex:relatedList subject="{!sb.Order_Line__c}" list="osstom__Work_Orders__r" rendered="true"/>
 </apex:repeat>

-->

 

Problem is, first time its working fine and showing correct Workorder(relatedlist), but from the next repeat its showing the same WorkOrder again and again , though the {!sb.Order_Line__c} is different.

 

How is your one working????

 

bob_buzzardbob_buzzard

Most odd.  The only real difference I can see is that your subject is a related id rather than the record itself, but I've tweaked mine to use the account parent and it still works as expected.

 

Have you tried outputting some more information about sb prior to the related list just to confirm you definitely have a different object instance each time through.  I can't see how that wouldn't be the case, but it would exclude that possibility.

BRBR

Yup. I also thought abt that . So i checked and had different ID in every repeat.  That means its passing different object id every time. but why its showing same related list object again that i cant find out ......

bpigginsbpiggins
Was the difference here ever determined? Did you ever get this to work? Is it standard vs. custom object?
bpigginsbpiggins
Bob, I have found that you're example does not work with the CombinedAttachments related list, but it does work with Opportunities.

I have also tried this with a custom object, using CombinedAttachments, and it works if recordSetVar provides the list of records. We get a unique related list for each record. But if the list comes from a query inside an extension, the CombinedAttachments related list is not unique for each record, even though the Salesforce record Id is unique.