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
softcloud2009softcloud2009 

Get the Opportunity ID from VisualForce page

I have a custom object (Quote) that is master-detail relationship with Opportunity.

I also created a custom VF page for my quote page.

On save button event, I would like to do insert to my quote custom object and it requires me to provide the Opportunity ID from which I created this quote.

 

How can I get an opportunity ID since my standardController is actually my custom object?

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

In your controller you can do the following:

 

 

      String id=System.currentPageReference().getParameters().get('id');

 

 

 

 

All Answers

bob_buzzardbob_buzzard

How do you get to the quote page?  If it is from a button on the opportunity, the id should be passed through on the URL.  If not, presumably the user will need to select the opportunity?

softcloud2009softcloud2009

Yes, it is through a button in opportunity and I attached the ID on the URL.

How to get the query string in visualforce page?

bob_buzzardbob_buzzard

In your controller you can do the following:

 

 

      String id=System.currentPageReference().getParameters().get('id');

 

 

 

 

This was selected as the best answer