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
Lisa KhazinaLisa Khazina 

Copy related list of a parent object to a child's page layout

Hi all!

I would greatly appreciate it if you could help me with this problem. I have read the topic (http://blog.jeffdouglas.com/2009/05/08/inline-visualforce-pages-with-standard-page-layouts/) about adding inline visualforce page to the page layout however, I don't know how to create this visualforce page correctly. 
I have a custom object "Clients' Groups" that has a Master Detail (MD) relationships to the custom object "Cases". I also have a junction object that has two MD relationships to "Clients' Groups" and object "Clients". 
"Clients' Groups" has a related list with all "Cases" related to this Group. If there is an opportunity to see this related list with all cases from the particular group on each particular Case from this group? 

Thank you!
NagendraNagendra (Salesforce Developers) 
Hi Lisa,

By using a trigger you can copy the relationship down, but I would probably instead do a custom Visualforce page to embed in your page layout. Use the lookup on the child object to query for all the objects related to the parent.
This would keep your objects simple/less cluttered while still displaying the information.

                                                   (OR)

You could use a Flow with a Loop. Do a Fast Lookup of the Parent's Vendors, then through a Loop change the variable for the Id of the Parent to the Id of the child. From that Loop, you then do a Record Create and create those records to the Child.

                                                   (OR)

Displaying  parent object details in child object's page layout without visual force page:

The only way to do this without using Visualforce page is to create a list button and use the script something as the below

http://{!URLFOR($Action.Contact.NewContact,'',[accid=Account.Id,name_firstcon2="Ramu",name_middlecon2="Adep"])} (http://{!URLFOR($Action.Contact.NewContact,'',[accid=Account.Id,name_firstcon2="Ramu",name_middlecon2="Adep"])})

For example, if you want to create a new contact record from the related list of Account record, you would need to follow the steps below

1. Go to Setup-->Customize-->Contact-->Buttons, Links and Actions
2. Click 'New button or link'
3. Enter the label name
4. Select the Display type as 'List Button'
5. Enter the above script in the body formula/script editor section.

Points to Noted : If you want to add more values from the parent record, all you would need to do is get the corresponding id of the child object field. How would you do it? it is simple, if you are working on chrome/Mozilla right click and go to Inspect element. Review the link corresponding to that field, you would find the id of that particular field. Copy the id and put it in the script you can put as many number of fields as possible separated by commas

You can review more about URLFOR in the below article
http://salesforcesource.blogspot.sg/2008/12/urlfor-function-finally-explained.html


Please mark this as solved if it's resolved.

Best Regards,
Nagendra.P
Lisa KhazinaLisa Khazina
Hi Nagendra, 

Thank you very much for your response.
I tried to create a visualforce page that displays parent's related list and add it to the child page layout. It did not work. I tried to create two visualforce pages and include parent's page into the child's page, however it did not work eather. 
I also tried to display quary result in the visualforce pages, however it needs to have a dinamic quary, not static, so I did not know how to create such quary and insert it into a visualforce page. 
I don't think that a Flow with the Loop will work for me - I don't need any actions, just need to see all child records from the each child's record page. 

Could you please explain the first variant that you have suggested, with a trigger? 

Thanks again, 
I am very grateful to you for your help. 
NagendraNagendra (Salesforce Developers) 
Hi Lisa,

Please find the below post from the community boards and modify the code as per your requirement in vice-versa which might help you to accelerate further.

https://developer.salesforce.com/forums/?id=906F00000008n12IAA

Hope this helps.

Best Regards,
Nagendra.P