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
Lorant DobrondiLorant Dobrondi 

Visualforce page to create related custom record on Opportunity

Hello,

I have this custom object that describes a Client Visit, and it's related to an opportunity (there's a Master-Detail Relationship on this custom object to the Opportunity object).

I want to be able to create a "Client Visit" related record from the Opportunity page layout, and I understand that to achieve this, I will have to create a Visualforce page.

I also need to do it in Visualforce, because I have the following requirement: if the user selects "Group Visit" from the type picklist, then 2 new fields should pop up on the view, where the user could select an additional User, who was there at the client visit. (I can see that this is not doable with simple record pages, or even flows.)

Now my question is the following: How should my page tags look like in order to be able to
1. Be able to select the Visualforce page from the Page Layout editor on the Opportunity object (which means that I would have to have the Opportunity as the standardController...??)
2. Create a "Client Visit" record
Deepali KulshresthaDeepali Kulshrestha
Hi Lorant,

I went through the query of yours and found some links which can assist you in solving your problem.
Please refer to the following links as they may be helpful in solving your problem:
https://salesforce.stackexchange.com/questions/244697/create-a-custom-button-on-a-custom-related-list-that-simply-adds-other-opportuni
https://developer.salesforce.com/forums/?id=906F0000000g215IAA

 I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha