• tejaswi dahariya 10
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
HI Guys.

Cant seem to get the Opportunities to appear under the child accounts when querying with the below codes. I can get all opportunities associated to the parent account however not able to display the Opportunites under the child accounts.

Any help would be awesome, see below for codes.

SOQL Query
public class GetAccountContacts {        
    public List<Account> getAccConCases(){
        return [select id, Name, Siebel_Row_Id__c, Parent_Accounts__c, (select id, Name from Account.Contacts) , (select id, Name from Account.Child_Accounts__r), (select id, CaseNumber from Cases), (select id, Name, AccountId from Account.Opportunities) from account where (Siebel_Row_Id__c != null Or Parent_Accounts__c != null)      LIMIT 10];
    }                   
}
VF Page displaying the results. Works like a tree map. 
<apex:repeat value="{!AccConCases}" var="a">
            <ul>
                <li>
                    <span><i class="icon-folder-open icon-plus-sign"></i>Parent Account</span> <a href="/{a.Id}"  target="_blank">{!a.Name}</a>
                    <ul>
                                        
                          <apex:repeat value="{!a.Opportunities}" var="op">
                            <li>
                                <span><i class="glyphicon glyphicon-briefcase"></i> Opportunity</span><a href="/{!op.Id}" target="_blank"></a> {!op.Name}
                            </li>
                          </apex:repeat>   
   
                        
                          <apex:repeat value="{!a.Child_Accounts__r}" var="ch">
                            <li>
                                <span><i class="glyphicon glyphicon-user"></i>Connection Accounts</span><a href="/{!ch.Id}"  target="_blank"></a> {!ch.Name}
                                <ul>
                                
                                    <apex:repeat value="{!a.Opportunities}" var="op">
                                        <li>
                                            <span><i class="glyphicon glyphicon-briefcase"></i> Opp</span><a href="/{!op.Id}" target="_blank"></a> {!op.Name}
                                        </li>
                                    </apex:repeat>
                                    
                                </ul>
                            </li>
                        </apex:repeat>                      
                    </ul>
                </li>
            </ul>
        </apex:repeat>

What it looks like currently, im looking to get opportunities to appear under the Child Accounts also.
User-added image