function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ShikibuShikibu 

How to construct an url with retUrl?

I'm  trying to display a value (pulled from a salesforce record by apex) on a VF page, and have it linked in the browser to a the standard salesforce edit page for the value.

 

The following does not work; I get to the edit page ok, but when I click save or cancel, I end up at the tab home page for the custom object. But no error.


How are urls with retUrl constructed?

 

 

// In the controller extension:

 

public String getexpenseRatioLink() { return StatisticalDatum.page( dataMap, 'expense ratio' ).getUrl() + '/e' + '?retUrl=' + ApexPages.currentPage().getUrl(); }

 

// In the VF page:

//

// <a href="{!expenseRatioLink}">{!expenseRatio}</a>
 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
XactiumBenXactiumBen
If it's a standard salesforce page you are creating a link for retUrl should actually be retURL (url is all capitals).  Also, consider URL encoding the retURL parameter (in case ? or & is included in ApexPages.currentPage().getUrl()) which can be done by using EncodingUtil.urlEncode(url, encodingscheme);

All Answers

Mikko4Mikko4

Hi,

 

You could try with adding only the id of the record/page after ?retUrl=

 

XactiumBenXactiumBen
If it's a standard salesforce page you are creating a link for retUrl should actually be retURL (url is all capitals).  Also, consider URL encoding the retURL parameter (in case ? or & is included in ApexPages.currentPage().getUrl()) which can be done by using EncodingUtil.urlEncode(url, encodingscheme);
This was selected as the best answer