+ Start a Discussion
Skip KSkip K 

Redirecting using PageReference

I'm redirecting to an edit page for an Opportunity. I had called the apex class from a view state of an Opportunity using a custom clone button. So I create a new Opportunity in the class and then want to forward to the new Opportunity's edit page. It looks like this:
​PageReference oppPage = new PageReference('/' + newOpp.Id+'/e');
return oppPage;
It takes me to the new Opportunity's edit page. The problem I'm having is that from the edit page the save button goes to the home page instead of the view state for the new Opportunity.

Is there any way that I can have the save button from the new Opportunity's edit page go to the view page instead of the home page? Possibly overriding the save functionality? I'm hoping to not have to create a new VF page. . . but I think that may be what I have to do. 

Thanks in advance.

 
Best Answer chosen by Skip K
KaranrajKaranraj
You don't need to override the save button, just simply pass the id of the record in the retURL inhe parameter
​PageReference oppPage = new PageReference('/' +newOpp.Id+'/e?retURL='+newOpp.Id);
return oppPage;

 

All Answers

KaranrajKaranraj
You don't need to override the save button, just simply pass the id of the record in the retURL inhe parameter
​PageReference oppPage = new PageReference('/' +newOpp.Id+'/e?retURL='+newOpp.Id);
return oppPage;

 
This was selected as the best answer
Skip KSkip K
That was easy. Thanks! Is there documentation that explains all of the potential url parameters for future use?

Thanks again!