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
SwapnilSwapnil 

Site.login startUrl returning only 1st parameter

Hi I have following piece of code,

 

startUrl = '/home?a=' + value1 + '~b=' + value2;
PageReference page = Site.login(username, password, startUrl);

String temp = page.getParameters().get('retURL');
temp = temp.replaceAll('~', '&');
page.getParameters().put('retURL', temp);

return page;

 

Here the returnURL shows the correct url but after the actual redirect it just redirects to the page with the 1st parameter, so i get

 

'/home?a=' + value1

 

which is wrong.... 

 

Pradeep_NavatarPradeep_Navatar

Can you provide more information, as to from where are you retrieving the retURL and whats the purpose of replacing a  ~, when you are creating the startURL by your own.

 

If your previous page has some retURL and you are trying to override it, so I guess that’s not required, as Site.login will pick the startURL only and will redirect your page correctly.

SwapnilSwapnil

So basically the problem is when I am passing startUrl to Site.login method it gives me a return URL but the retURL only contains the 1st parameter and discard rest of the parameters. I want to retURL to have all the parameters.

 

So I am not getting the correct retURL.....

asish1989asish1989

hi

can any one tell me  where should i give the value of startURL...?

GregNYCGregNYC

I finally figured out a solution to this problem - it has to do with URL encoding.  If you replace all ampersand values in your startURL parameter with the URL-encoding reference %26, it will solve your problem, and all the parameters initially passed in will persist when your user hits the ultimate destination.

 

If you previously had something like:

 startUrl=/home?a=value1&b=value2

 

Try switching it to this:

 startUrl=/home?a=value1%26b=value2