You need to sign in to do that
Don't have an account?

URLFOR & retURL
Hello folks,
Can someone advise me as to how we can get the return URL of a page in a visualforce controller ? My assumption is that it is not possible for VF controller to know from which page it was invoked. So , in order to pass the retURL as a URL parameter(yes, I am calling the visualforce page using a s-control URL), how can I retrieve the same. For e.g.: if I am on a Accounts List page, how do I retrieve its URL ? [on click of a custom button on the Accounts List page, I invoke the VF page using JS NavigateToURL).
Any help would be greatly appreciated !
Thanks,
A B
Message Edited by Arun Bala on 12-10-2008 01:47 PM
Message Edited by Arun Bala on 12-10-2008 01:48 PM
Can someone advise me as to how we can get the return URL of a page in a visualforce controller ? My assumption is that it is not possible for VF controller to know from which page it was invoked. So , in order to pass the retURL as a URL parameter(yes, I am calling the visualforce page using a s-control URL), how can I retrieve the same. For e.g.: if I am on a Accounts List page, how do I retrieve its URL ? [on click of a custom button on the Accounts List page, I invoke the VF page using JS NavigateToURL).
Any help would be greatly appreciated !
Thanks,
A B
Message Edited by Arun Bala on 12-10-2008 01:47 PM
Message Edited by Arun Bala on 12-10-2008 01:48 PM
so, it would be something like
https://cs2.salesforce.com/a0SR0000000WUpL/e?retURL=%2Fa0SR0000000WUpL
String retURL = System.currentPageReference().getParameters().get('retURL');
You may be able to use ApexPages.currentPage().getParameters().get('retURL'); but I'm not sure.
Message Edited by TehNrd on 12-10-2008 02:27 PM
Appreciate your quick responses. But still I would need your help :-)
Looks like my question was not clear. I am rephrasing it as below to clear the ambiguity in my question:
1. I open the accounts tab and view the recently created accounts.
2. Here I also have a custom button called 'X' on the Accounts view page (recently created accounts). On click of the button, I execute a JS to do some validations and then do a NaviagateToURL(Visualforce page URL). The visualforce page URL doesnt have the 'retURL' appeded to it. My question is how can I frame the return URL , that will help me return back to the accounts view page displaying recently created accounts.
3. The visualforce page also opens up . But in the controller, if I do a System.currentPageReference().getParameters().get('retURL');, nothing will be returned as I am not passing the retURL.
What I noticed is even if I do a URLFOR('/apex/vfpage',null,null), the retURL is not getting appended.
Many a thanks,
Arun B
Message Edited by Arun Bala on 12-10-2008 04:57 PM
If the button is executing an onclick javascript you should easily be able to append the retURL to the url:
I don't think my syntax is correct but you can get the idea.
String url = '/apex/mypage?id={!Opportunity.Id}&retURL={!Opportunity.Id}';
I got your idea. Had it been returning to a particular account page, I would have used that method. But I need to return back to the Account View page (the page that lists my latest filter criteria - Recently view accounts or Recently created accounts.
My URL on the account view page currently looks like : https://na1.salesforce.com/001?fcf=00B300000031lHm. But I am not sure how can I get this id 00B300000031lHm or the inbuilt return URL (retURL=%2F001%3Ffcf%3D00B300000031lH).
Message Edited by Arun Bala on 12-10-2008 05:19 PM
Message Edited by Arun Bala on 12-10-2008 09:08 PM