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
Nagarjuna Reddy.PNagarjuna Reddy.P 

parent child fields to autopopulate in vf page created on another child of same parent.

Hii ,
              I have three objects A,B and C.here B is parent to A and C.There is no relation between A and C.Now I created a vf page on A,when i select Parent look up field B its fields are to be autopopulated along with the C object  records which are child to  B.How to achieve this.I hope this is a good challenge to lot of people.
Thank you. 
Dheeraj VarmaDheeraj Varma
Hi, 
According to your question, C is a child of B. How do I select which child record data to populate if B has multiple children records of C associated with it.

If suppose you have a logic that will filter out the one C record that can be used to prepopulate the data, here is what you can do.
  • Use the onchange on the inputfield (lookup field) to call an action function which in turn calls the apex method.
  • In the apex method do an soql query on the C object where parent  id equal to the selected B record (add other filter conditons to identify the one particular C record that can be used to prepopulate).
  • Now use the record obtatined to populate the respective fields of A object record
  • Now use the rerender attribute of the action function to rerender those sections/blocks that will have the populated fields to see the updated values.