+ Start a Discussion

How to get child records based for each master object record ???

Hi All,

I have two objects



there is master-detail relationship b/w these objects 

each Stock transfer have 1 or more than Stock transfer lines

now these records should display in one page 

for suppose StockTransfer having 2 fields 1,location1 2,location2

and StockTransferLine has 3 fields 



3,request date


now these values I want to show in table


Source location    Destination location        item  ID            quantity         Request date

USA                           India                                 0001                100               3/3/2012



please any would help me or provide some sample code.

Thanks in Advance.                                       


The first thing would be to write a SOQL query in an Apex Controller which returns the results you want.

You can do something like


SELECT stocktransfer__r.location1,stocktransfer__r.location2,item,quantity,request_date from StockTranferLine

 This is just an example - you would need to use the actual names of your objects/fields.


Then you would return this to visualforce and use a table or repeat component to display the results.


This is a an example you could try to copy:



Doesn't sound like there is anything here needing a custom controller.   Seems like standard controller would do this easily.   There are lots of examples in the documentation. 


Hi Aballard,

Would you please provide the links. It ll be helpful for me.


Thanks in Advance.