Reply
Regular Contributor
"Man"ish
Posts: 79
0

Display parent detail page with child detail records in a Visualforce page

Hi All,

 

I need to display the parent detail page with the detail pages of all the related lists in a single visualforce page (Not worried about the length of the page)

 

Ex: I have myCustomObject__c as a related list under Account.

 

I would like to display Account detail page using <apex:detail>. Along with this, I need to add the <apex:detail > of the related records as well.For this I used  <apexx:detail> in <apex:repeat> tag.

 

<apex:page standardController="Account" extensions="DominoController" id="thePage">
    <apex:detail subject="{!Account}" relatedList="false"/>
    <apex:repeat var="o" value="{!oList}" id="theRepeat">
        <apex:detail subject="{!o}"/>
        <hr/>
    </apex:repeat>
    <!-- repeat tag is for repaeting the related list records of the account -->
</apex:page>

####################

public with sharing class DominoController {
    public sObject[] oList{ get; set;}
    public Account Acc;
    public String soqlQuery;
    
    public DominoController(ApexPages.StandardController controller) {
        this.Acc = (Account)controller.getRecord();
        
        soqlQuery = 'select id, Name from MyCustomObject__c';
        //soqlQuery holds all the custom object records of all Accounts
        oList= Database.query(soqlQuery);

            }
}

 

It displays the Account page fine. Below it, the detail page of all the related custom object records are also displayed. The problem is it display all the MyCustomObject records of all the Accounts, not just for this Account.

 

To get only this Account related list, I added WHERE condition in the soqlQuery,

 

soqlQuery = 'select id, Name from MyCustomObject__c where Account_Name__c='+Acc.Id;

 

but it throws the following error.

 

                   unexpected token: 'O00000074Mr8IAE'

 

                   An unexpected error has occurred. Your development organization has been notified.

 

 The ID mentioned here is the Account ID of the record I am trying to open.

 

 Any suggestions please?  

Regular Contributor
SK R
Posts: 44
0

Re: Display parent detail page with child detail records in a Visualforce page

Hi,

 

Looks like you are comparing Name (Account_Name__c) with Id in the Query, check it once.

Regular Contributor
"Man"ish
Posts: 79
0

Re: Display parent detail page with child detail records in a Visualforce page

No, its a lookup field. It has ID in it.

 

Anyways, I did try with Customer_Name__r.Id, no change. Error.