I've tried something like this

    PageReference pr = ApexPages.currentPage();

but that doesn't seem to have worked as the id returns on the next page.

  • Did you mean to write ApexPages.currentPage();ApexPages.currentPage().getParameters(); or is that a typo? Jan 19, 2016 at 22:38
  • Are you going to redirect to a new page?
    – cropredy
    Jan 19, 2016 at 22:42
  • @CasparHarmer no, good catch. Jan 20, 2016 at 14:31
  • @crop1645 yes, eventually on this page. Jan 20, 2016 at 14:32

1 Answer 1

PageReference currPr = ApexPages.currentPage();
PageReference newPr = new PageReference('/apex/myPage');
for (String parm : currPr.getParameters().keySet())
     if (parm.equalsIgnoreCase('id') {}
     else newPr.getParameters().put(parm,currPr.getParameters().get(parm));

return newPr;

There is a good blog post by Dave Helgerson that covers various permutations

You must log in to answer this question.

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