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
Sumit SachdevaSumit Sachdeva 

page reference not redirecting properly and stripping parameters

Hi,


I am trying to create a url in my class
it gets created corectly and i am able to see it in debug log
but when i pass it to the pagereference it does not redirect correctly. and it strips the parameters out of the url
this is in my sandbox (Full). Please help.

it should redirect to
/merge/accmergewizard.jsp?goNext=+Next+&cid=001b000000Fva5qAAB&cid=001b000000RvToJAAV&cid=001g000000RUAhaAAH


but it redirects to
/merge/accmergewizard.jsp?cid=001b000000Fva5qAAB&goNext=+Next+

please let me know why this is happening and steps to resolve it

thank you so much

Sumit
Himanshu ParasharHimanshu Parashar
Hi Sumit,

You are passing three parameters in same cid variable that is why it is taking only first parameter. This is causing this issue.

if you want to pass multiple values in that separate them using any delimiter such as ; or , or - and then break on the basis of delimiter in your controller.


Thanks,
Himanshu
Sumit SachdevaSumit Sachdeva
Hi Himanshu,
I understand your point and agree with that. But this is the standard syntax and modifying the parameter identifier to cid1 or cid2 breaks the URL. 

I did not completely get what you said in the second line. 
please find below my code and advise what should be changed:
public PageReference search() {
        
        String pageRefString = '';
        accountList = new List<Account>();
        accountList = [Select id from Account where FSR_Reference_Number__c = :searchitem];

        if (accountList.size() > 0) {
            for(integer i=0; i < accountList.size(); i++) {
                system.debug('pageRefString: '+pageRefString );
                pageRefString = pageRefString + '&cid='+ accountList[i].id;
            }
        }      
        pageRefString = '/merge/accmergewizard.jsp?goNext=+Next+' + pageRefString;
        system.debug('final pageref: '+pageRefString);
        PageReference pageRef = new PageReference(pageRefString);
        pageRef.setRedirect(true);
        return pageRef;
    }

Thanks for all your help.
Himanshu ParasharHimanshu Parashar
Hi Sumit,

Pageref cut down identical parameters from the url so only option you have is prepare url string in controller side and use javascript to redirect user on oncomplete event.
 
<apex:outputPanel id="jspanel">
    <script>       
            pageurl = '{!pageRefString}';            
            window.location.href = pageurl;            
    </script>
</apex:outputPanel>

<apex:commandbutton action="{!search}" rerender="jspanel"/>
It should work.

Thanks,
Himanshu
APatAPat
Hi Sumit,

Try this and let me know if it works or no.

pageRefString = '/merge/accmergewizard.jsp';
system.debug('final pageref: '+pageRefString);
PageReference pageRef = new PageReference(pageRefString);
pageRef.getParameters().put('Name1','Value1');
pageRef.getParameters().put('Name2','Value2');

pageRef.setRedirect(true);

Hope this helps.