+ Start a Discussion
Olga Kim 5Olga Kim 5 

Visualforce Page PDF with three related object values?

Is it possible to create a PDF Page that contains values from three related objects?

If it is, how would I do that? 

Thank you, in advance!
Best Answer chosen by Olga Kim 5
ANUTEJANUTEJ (Salesforce Developers) 
Hi Olag,

I think you can have an soql to get the records from related objects using the relationship between them and below is the link to them "https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_limits.htm#:~:text=No%20more%20than%2020%20parent,Account."

Additionally I also found a simple example with contact records in visualforce page as pdf.

Link: https://developer.salesforce.com/forums/?id=906F00000008oVEIAY
<apex:page renderAs="PDF" standardController="Account">
    <apex:pageBlock>
        <apex:pageBlockSection>
            <apex:pageBlockTable value="{!Account.Contacts}" var="con">
                <apex:column value="{!con.Name}" />
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Olag,

I think you can have an soql to get the records from related objects using the relationship between them and below is the link to them "https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_limits.htm#:~:text=No%20more%20than%2020%20parent,Account."

Additionally I also found a simple example with contact records in visualforce page as pdf.

Link: https://developer.salesforce.com/forums/?id=906F00000008oVEIAY
<apex:page renderAs="PDF" standardController="Account">
    <apex:pageBlock>
        <apex:pageBlockSection>
            <apex:pageBlockTable value="{!Account.Contacts}" var="con">
                <apex:column value="{!con.Name}" />
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej
This was selected as the best answer
Olga Kim 5Olga Kim 5
Thank you this is helpful.

I am wondering can use SOQL to retrieve data from grandchildren's records? I have three related objects (parent, children, and grandchildren) I need to display values on Visualforce PDF from all three objects.

Many thanks,