0

The below Account Redirect page for EDIT is working fine for VF pages but for standard layouts after editing the record it is not returning home page instead of account detail page.

Am i missing something here?

public with sharing class DispatcherAccounteditController {
public DispatcherAccounteditController(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public PageReference getRedir() {
Account acc = [Select id, recordtypeid From Account Where Id = :ApexPages.currentPage().getParameters().get('id')];

        PageReference newPage;

        if (acc.recordtypeid == '0123B000000Hs88') {
            newPage = Page.AccountEdt;
        } else {
            newPage = new PageReference('/' + acc.id +'/e');
            newPage.getParameters().put('nooverride', '1');     
        }
             newPage.getParameters().put('id', acc.id);

             return newPage.setRedirect(true);

    }

    private final ApexPages.StandardController controller;

}
0

You need to add retURL in Url parameters. So your code would be like:

public with sharing class DispatcherAccounteditController {
   public DispatcherAccounteditController(ApexPages.StandardController controller) {
      this.controller = controller;
   }

   public PageReference getRedir() {
      Account acc = [Select id, recordtypeid From Account Where Id = :ApexPages.currentPage().getParameters().get('id')];

      PageReference newPage;

     if (acc.recordtypeid == '0123B000000Hs88') {
        newPage = Page.AccountEdt;
     } else {
        newPage = new PageReference('/' + acc.id +'/e');
        newPage.getParameters().put('nooverride', '1');

 newPage.getParameters().put('retURL', ApexPages.currentPage().getParameters().get('retURL'));
     }
        newPage.getParameters().put('id', acc.id);

        return newPage.setRedirect(true);

}

private final ApexPages.StandardController controller;
}
0

You are putting id parameter twice in URL when recordtypeid is not matching with the mentioned one, i.e. when else is executed. Try after moving newPage.getParameters().put('id', acc.id); code block in IF part.

  • Hi Ashish, the issue i am facing is, if the detail page is a vf page, then after an adit made to the record it is perfectly redirecting to the vf detail page. However if the detail page is standard layout then then after editing the record it is redirecting to home page instead of the standard record detail page. – Nanda Kishore Apr 22 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.