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 '16 at 22:38
  • Are you going to redirect to a new page?
    – cropredy
    Jan 19 '16 at 22:42
  • @CasparHarmer no, good catch. Jan 20 '16 at 14:31
  • @crop1645 yes, eventually on this page. Jan 20 '16 at 14:32
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

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.