3

Related: Can I send a user to a standard layout edit page at the end of a wizard?

I have implemented a wizard that sends the user to the standard edit page at the end of the wizard. It's working wonderfully! The only problem I'm facing is the next step.

According to SFDC docs, the standard edit action:

Navigates the user to the edit page for the record that is currently in context. After this operation is finished, the edit action returns the user to the page where the user originally invoked the action.

This means I'm being sent back to the wizard, when I'd really much rather be on the standard detail page. Is there a normal way to do this?

2 Answers 2

3

I went with this solution: http://www.comitydesigns.com/wp/2011/07/21/navigating-to-other-locations-within-sfdc-after-editing-a-record-saveurl-vs-returl/

In short, I added a retUrl param to the url for the cancel action and a saveUrl param for the save action.

The code looks something like this:

  String editPageUrl = new ApexPages.StandardController(getCall()).edit().getUrl();
  System.debug('editPageUrl = ' + editPageUrl);

  Map<String, String> newQueryParams = new Map<String, String>();
  newQueryParams.put('retUrl', new ApexPages.StandardController(getCall()).view().getUrl());
  newQueryParams.put('saveUrl', new ApexPages.StandardController(getCall()).view().getUrl());

  // I wrote setQueryParameters to take in a map of params-to-vals and 
  // replace those query parameters in the url string.
  String alteredUrl = UtlilityClass.setQueryParameters(editPageUrl, newQueryParams);

  System.debug('alteredUrl = ' + alteredUrl);
  PageReference resultPage = new PageReference(alteredUrl);

  resultPage.setRedirect(true);

  return resultPage;
2
  • Hi Charles, even i am implementing the same thing. After editing the record & clicking on save or cancel it is going to homepage showing dashboard rather than going to detail page. But in my case detail page is a custom page. Can you please help. Currently m using (return new PageReference('/' + headClone.Id + '/e'); )to return to edit page after this i want to be returned to detail page on clicking save or cancel.
    – user12051
    Apr 23, 2015 at 8:03
  • @user12051 This solution should work just fine for you, Just replace new ApexPages.StandardController(getCall()).view() with Pagereference.YOUr_PAGE_NAME Apr 23, 2015 at 12:16
1

return new PageReference('/' + newRecordId +'/e?retURL=%2F'+newRecordId);

this worked for me. May be this can help.

You must log in to answer this question.

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