1

I've tried something like this

    PageReference pr = ApexPages.currentPage();
    pr.getParameters().remove('id');

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? – Caspar Harmer 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. – Embattled Swag Jan 20 '16 at 14:31
  • @crop1645 yes, eventually on this page. – Embattled Swag Jan 20 '16 at 14:32
2
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));

newPr.setRedirect(true);
return newPr;

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

| improve this answer | |

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.