I have called NextStep() on Button Click where I wanted to open a standard VF page provided by SF with some new additional parameters in URL - where my string MergeURL is just fine, but it gets changed when I try to open that URL using PageReference !!

Apex Code :

  public PageReference NextStep(){
   -----Some Code ----------
   System.Debug('----URL--'+MergeURL);   //****** THIS PRINTS THE URL CORRECT WHICH I Want to open 
   PageReference mergePage = new PageReference(MergeURL);
   return mergePage;

Debug Log :


02:16:27.093 (93221171)|SYSTEM_METHOD_EXIT|[24]|System.debug(ANY) 02:16:27.093 (93234760)|SYSTEM_METHOD_ENTRY|[26]|MyController.__sfdc_MergeURL() 02:16:27.093 (93248291)|SYSTEM_METHOD_EXIT|[26]|MyReference.setRedirect(Boolean) 02:16:27.093 (93384265)|SYSTEM_METHOD_EXIT|[27]|System.PageReference.setRedirect(Boolean) 02:16:27.093 (93416963)|SYSTEM_MODE_EXIT|false 02:16:27.093 (93458930)|CODE_UNIT_FINISHED|MyController invoke(NextStep) 02:16:27.093 (93537389)|VF_APEX_CALL|j_id4|{!NextStep}|PageReference:/some/some.jsp?cid=00190000012UXZiAAO&goNext=+Next+ 02:16:27.347 (95579984)|CUMULATIVE_LIMIT_USAGE

Any Suggestions !!!

  • 1
    What standard page is that? This sounds too hackish to me. Even if you get it work it could break anytime if Salesforce decides to change that page.
    – PepeFloyd
    Commented Sep 11, 2014 at 9:32
  • 1
    In your url both parameters are called cid and so, probably, the duplicate is removed. What happens if you call the second one something else? Commented Sep 11, 2014 at 9:45
  • I am calling merge/accmergewizard.jsp?goNext=+Next+&cid=SOMEID &cid=SOMEID Commented Sep 11, 2014 at 10:12
  • I think Javascript could be the solutions, but I am unaware of it ! Commented Sep 11, 2014 at 10:13
  • @RichardDurrant : I have to call "cid" only since I wanted to open all those records on next page, I cant use anything else. Yes PageReference is removing duplicates, so is there any other way i can do it,. Commented Sep 11, 2014 at 10:30

2 Answers 2


I don't think that the PageReference object is going to allow you to have multiple identical parameters. Your best bet is to open the url in Javascript, like so:

onclick="window.location='/merge/accmergewizard.jsp?goNext=+Next+&cid={!acct1.Id} &cid={!acct1.Id}'" 

Instead of having an apex:commandButton use an <input type="button"> with the onclick code above as an attribute.


I got solution finally by trying too many ways -

VF Page :

<apex:outputPanel id="redirect">
            url = '{!JSINHTMLENCODE(MergeURL)}';            
            var div = document.createElement('div');
            div.innerHTML = url;
            var decoded = div.firstChild.nodeValue;
            window.parent.location.href = decoded;            

on my Button Click where I am calling NextStep(), I rendered "redirect" which is above panels id. And It worked as I required.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .