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.

4
  • 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
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

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.