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
Paul FoleyPaul Foley 

Visualforce refresh page and keep additional query string parameters

I'm having some trouble retaining a query string parameter on a page when i save it. 

My URL is along the lines of:
https://c.cs22.visual.force.com/apex/testPage?id=ABC123&uid=37b5a9a2-4541-46ad-b10a-fc4592793070
Where ABC123 is the id of the record I'm referencing.

Whenever I click the save button, and the save function is called in the corrosponding Apex class it redirects the user back to the page as expected, but the second parameter (uid) is missing.

I've included the guts of my save function below
public PageReference save(){
        PageReference currentPage = ApexPages.currentPage();           
        Map<String,String> currentPageParameters = currentPage.getParameters();
        PageReference nextPage = new PageReference('/apex/testPage');
        nextPage.getParameters().put('uid',currentPageParameters.get('uid'));
        
        // a bunch of code to actually save the data.
            
        return nextPage;
	}
I've tried a couple of examples from other pags but had no joy getting this working.
Edwin VijayEdwin Vijay
try this
 
public PageReference save(){
        PageReference currentPage = ApexPages.currentPage();           
        Map<String,String> currentPageParameters = currentPage.getParameters();
        PageReference nextPage = new PageReference('/apex/testPage');
        nextPage.getParameters().put('uid',currentPageParameters.get('uid'));
        
        // a bunch of code to actually save the data.
        nextPage.setRedirect(true);        
    
        return nextPage;
	}