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
Tre PedigoTre Pedigo 

Using Apex Class and VF to view details of an opportunity's related account

Hi there,
I have created a custom tab for my opportunities and have attached my vf page's URL. I want to be able to go into this tab under any given opportunity and see certain details of the account it is related to. It seems that for this to work, the record id for the opportunity needs to be manually input, but my requirements say the process must be automated. In other words, I need to modify my vf page to recognize which opportunity is being viewed and to automatically include the respective account id in its own URL. Intuition tells me this must be done through the usage of a controller, but I'm not familiar enough with controllers to understand how to script this out. Any direction on how to do this would be greatly appreciated as this is the biggest obstacle I have come up against.  
David KevinDavid Kevin
In other words, I need to modify my vf page to recognize which opportunity is being viewed and to automatically include the respective account id in its own URL. mybkexperience (https://www.mybkexperience.onl) krogerfeedback (https://www.krogerfeedback.onl)
Prakash MathurPrakash Mathur
To automatically include the respective account ID in the URL of your VF page, you can indeed use a controller. You can create a controller extension for your VF page and retrieve the opportunity record ID using the Apex method "getRecordId()". Then, using the opportunity record ID, you can query for the related account ID and construct the URL with the necessary parameters. Finally, you can use the URL in your VF page to display the desired account details. Let me know if you need further assistance with the implementation. Detective Agency in Delhi (https://trackeyedetectives.com/)