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
dummy74dummy74 

accessing a "detail" list from a master object record in a controller extension

Hello,

I'm quite new in SFDC.

 

I'm working on building a VF page, that needs to display the last transactions of a client, knowing that the object model is 

 

each client has a list of accounts

each account has a list of holdings

and finally, each holding has a list of transactions (buy, sell ... )

 

Each of these parent - child relationships is done through a master - detail relationship.

For instance, for the client - account, the client is the master and the account the detail.

 

I' m trying to build a extension of the client standard controller where I will implement a method that returns this list of transactions starting with the stdController.getRecord() object. I'm ok with the algorithm that I have to implement.

 

My point is that I don't know how to access the detail list from the parent object in Apex.

For instance, when I look at the list of attribute for my client, I don't see the account list.

 

Thanks for your help !

Jeff MayJeff May

One way would be to get the MasterIDs into a List or Set,then query the 'detail' records for those that have the MasterID.  You can store the results in map<Id, List<object>> using the MasterID as the key, and the detail record as the object.  that way, when you iterate over the master records, you can get all the detail records.