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
Dhairya MistryDhairya Mistry 

Adding Child Object's fields on Parent Object's PDF view via VisualForce.

Hi, 

Reltively new to VF and Apex. I have two custom objects - ObjectA__c (Parent Object), ObjectB_Line_Item__c (Child Object) connected via Master-Detail. I have created a button on Object A for rendering as PDF. I have ObjectB_Line_Item__c as related list on ObjectA__c.

I need to create a table of line items of ObjectB_Line_Item__c on ObjectA__c.

I used <apex:related list> as follows and was able to get the list but I need only few columns on the PDF instead of all columns I see on ObjectA__c related list. In short default view of related list is not ideal and I have not been able to find how to hide few columns in PDF while keeping current related list on ObjectA__c detail page as it is. 
<apex:relatedList list="ObjectB_Line_Items__r" title=""/>


 The objects are similar in behavior as Opportunity and Opportunity Line Item. Appreciate your help. 
Lokesh KumarLokesh Kumar
HI Dhariya,

You might need to write a custom controller or an extension. Then you can run a query, and use it in your VF page. Have you explored that route?
<apex:page standardController="Opportunity" showHeader="false" renderAs="pdf">
   <apex:pageblocktable value="{!Opportunity.bucketRate__r}" var="b" title="Bucket Rate Factoring Fee" >
      <apex:column value={!b.levelname__c} />
      <apex:column value={!b.lowdays__c} />
      <apex:column value={!b.highdays__c} />
      <apex:column value={!b.levelfee__c} />
   </apex:pageblocktable>
</apex:page>

Of course, you might have to adjust your list attribute name and the field names, but this should get you close.

Here is some information: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller.html (#