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
Shirley MaglioShirley Maglio 

How to display the original Account detail page, after ovrriding the standard Delete button in a related list?

Hi All,

I have overridden Salesforce’s standard Delete button in a Related List of an Account detail page. 

In order to override the standard Delete button, I have created a new Visualforce page with an Apex controller extension class.

How do I display the original Account detail page after I am done deleting?

Any help will be greatly appreciated!

Shirley
Best Answer chosen by Shirley Maglio
BalajiRanganathanBalajiRanganathan

The relatedList delete will have retUrl=<ID> in the URL Query String.

Use this in your Custom delete method on the Apex controller extension class to create the pagereference and return that page reference.

   String retUrl = ApexPages.currentPage().getParameters().get('retURL');
    if (!String.isBlank(retUrl )) {
      PageReference page = new PageReference('/' + retUrl);
      page.setRedirect(true);
      return page;
    }

All Answers

NekosanNekosan
You can use below code to get return url and then redirect to that page. 
var retUrl = '{!$CurrentPage.Parameters.retURL}';
BalajiRanganathanBalajiRanganathan

The relatedList delete will have retUrl=<ID> in the URL Query String.

Use this in your Custom delete method on the Apex controller extension class to create the pagereference and return that page reference.

   String retUrl = ApexPages.currentPage().getParameters().get('retURL');
    if (!String.isBlank(retUrl )) {
      PageReference page = new PageReference('/' + retUrl);
      page.setRedirect(true);
      return page;
    }
This was selected as the best answer
Shirley MaglioShirley Maglio
Hi Balaji,

Thank you very much for your help.

~Shirley