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

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);
| improve this answer | |
  • 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 '16 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.