function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
waylonatcimwaylonatcim 

Modify Parameters in current page's URL

I'm trying to edit a parameter in a page's url and then re-direct the user to the page with the modified url. 

I have tried the following:

 

 

PageReference pref = ApexPages.currentPage();
pref.getParameters().put('edit',paramVal);	
pref.setRedirect(true);
return pref;

 

But that just returns a blank page.

 

I've also tried:

 

PageReference pref = ApexPages.currentPage();	
pref = new PageReference(pref.getUrl());
pref.getParameters().put('edit',paramVal);
pref.setRedirect(true);

 

Which also returns a blank page.  I can get the page to redirect succesfully but using either of the following

PageReference pref = new PageReference('http://yahoo.com');

or

PageReference pref = ApexPages.currentPage();	
pref.setRedirect(true);

 

 

so I know my redirection is working.  Does anyone know what I'm doing wrong or know how I can accomplish what I'm trying to do?

 

Thanks

waylonatcimwaylonatcim

Using the following works, but I still don't understand why I need to add the extra to lines

 

pref.getParameters().clear();
pref.getParameters().put('id',pageTask.Id);
pref.getParameters().put('mode',paramVal);
pref.setRedirect(true);