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
Jatin Bansal 18Jatin Bansal 18 

Display specific related list on VF page


I have requirement to display only specific related list(License in this case) in VF. I tried using following code but no success. I am using apex:details to hide all related list and then apex:related list to show specific related list. I need to know 2 things:-
  • Why this code is not working ?
  • Is there a better way to approach this problem ?
<apex:page renderAs="pdf" showHeader="false" applyHtmlTag="false" applyBodyTag="false" controller="FulfillmentRequestListViewPdfExtension" action="{!updateDistributionStatus}">
<html>
    <head>
        <style>
            @media print {
                html, body {
                    height: 99%;
                }
            }
        </style>
    </head>
    <body>
        <apex:repeat value="{!frs}" var="fr" id="theRepeat">
            <apex:detail subject="{!fr}" id="theValue" relatedList="False" />
            
             <apex:relatedList list="Licenses__r">
              <apex:facet name="header">License Details</apex:facet> 
             </apex:relatedList>
            
               <div style="page-break-after: always;" />
        </apex:repeat>
    </body>
</html>
</apex:page>

License Object (Related List)
ArleneArlene
I believe that the name of the list is probably not Licenses__r.  It is what you called the relationshp when you set up the lookup or master/detail relationship.  I believe it would have defaulted to "Licenses".  You can find the child relationship name if you go to the Licenses object, and look at the field that links License__c to its parent (Fulfillment Request?) object.  I believe you will also have to add a subject= attribute so that the related list knows which record to display the related list for.