+ Start a Discussion
West415West415 

Append URL Parameters to PageReference?

Hi,

 

I have this code snippet and I'm trying to simply append some query string parameter to the end of it.  How can this be done?

 

public with sharing class MyCustomController {

 

  public PageReference login() {

    return SiteVariables.getLogin();
  }

 

}

 

I want to append a query string parameter to the end of the PageReference so when the "Login" page is returned it has a URL something like "http://site.com/apex/login?customerlocation=TX for example

 

In this example, "custoemrlocation" would be the variable with "TX" as the value.

 

Any help appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9
You can try something like this

public PageReference login() {
Pagereference pageRef = SiteVariables.getLogin();
pageref.getParameters().put('custoemrlocation','TX');
return pageRef;
}

All Answers

Bhawani SharmaBhawani Sharma
What all you need to do is, create a PegeReference instance first and it paramaters in it.
public PageReference login() {
PageRegerence pgRef = SiteVariables.getLogin();
pgReg.getParameters.put('custoemrlocation', 'TX');
return pgRef;
}
Avidev9Avidev9
You can try something like this

public PageReference login() {
Pagereference pageRef = SiteVariables.getLogin();
pageref.getParameters().put('custoemrlocation','TX');
return pageRef;
}
This was selected as the best answer
West415West415
Thanks...this appears to be what I'm looking for. I will try this shortly and post back my results.

Thanks again!