0

Their is a Configure button for our Managed package. Created a custom link on Home >Custom Link > To open the page in the same window with sidebar. now I am trying to redirect to the previous page when the save is successful or when the user clicks the cancel button. Tried the following but didn't work -

// custom controller member variables.
Public String baseURL;
Public String PageURL;

in the constructor - baseURL = URL.getSalesforceBaseUrl().toExternalForm(); 
        PageURL = ApexPages.currentPage().getUrl(); // this is returning my visualforce page. not the previous page.

public PageReference cancel(){
        String url = 'https://'+baseURL+pageURL;
         PageReference retURL = new PageReference(url);
       System.debug('retURL---'+retURL);
        return retURL;
    }

Thanks and appreciate all your help!!

1 Answer 1

0

It worked when I put the following code in controller constructor -

String referrer = Apexpages.currentPage().getheaders().get('Referer');
public PageReference cancel(){
        PageReference retURL = new PageReference(referrer);
        System.debug('--referrer--'+referrer);
        return retURL;
    }

You must log in to answer this question.

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