+ Start a Discussion
Mikron AdminMikron Admin 

Return URL for a page



When I cancel an operation on a Visualforce page, I would like to return to the calling page.


In my case, the Visualforce  page is invoked from a custom button placed on an object view.


Is it possible to get an object view URL? I tried, but I could not find a specific merge field to pass the current page URL as a parameter (retURL).


Use the Standard Controller {!Cancel} method to return to the previous view


<apex:commandbutton action="{!cancel}" value="Cancel"/>


otherwise, if you are using a controller extension you can use Page Reference



public PageReference cancel() { return new ApexPages.StandardController(c).view();}





You meant something like this ?


<apex:page standardController="opportunity">

Current page URL = {!$CurrentPage.URL} 



Or do you want a solution with an Apex controller?