0

I have overridden detail and edit pages of an object. So to override, the save functionality or the delete functionality - I need to redirect the user back to the page from where she came from. So in my VF page how do I get back the return URL. I want to do redirect from the controller using pageReference.

Thanks in advance.

1 Answer 1

1

If you click overriden button and look at your URL, you will see:

apex/yorpage?id=00136000002lG0u for detail
apex/yorpage?retURL=%2F00136000002lG0u for edit

So in your controller read this parameter:

returnURL = ApexPages.currentPage().getParameters().get('id'); or
returnURL = ApexPages.currentPage().getParameters().get('retURL');

And after everything is complete do return:

return new PageReference('/'+returnURL);
1
  • 2
    You can also use StandardController's cancel function, which basically has the same behavior of determining which parameter should be used.
    – sfdcfox
    May 18, 2016 at 5:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .