I'm sending some parameters to custom controller of my object, which should be populated on multiselect picklist. In controller I'm creating a new Page Reference, where I put all parameters by using myPage.getParameters.put('fieldId', 'paramValue'). This is for creating new instance of object with some fields preselected upon creating on creation page.

I need to set multiple values into multiselect field, and I'm trying to do it by joining all needed values with ;, but SF doesn't understand this.

Then, I'm put into Page Reference constructor URL with all values for this field 'myId=val1&myId=val2'. This also doesn't work.

Finally, I'm trying to put all into one parameter and send it as one value, like: myPage.getParameters.put('fieldId', 'val1&fieldId=val2'), but here I'm facing the problem of encoding all letters, including = and & which definitely should be kept as usual. Can anyone suggest how to do it through page reference?


You can't do this with a PageReference. The correct syntax is indeed myId=val1&myId=val2, but you can't codify this in a PageReference because the query string gets parsed in to a Map<String, String>. In order to redirect successfully, you'd have to use client-side JavaScript and use a normal string:

var redirurl = "{!redirect}";
if(redirurl) {
  window.location = redirurl;

There's absolutely no way to hack this with server-side code, as far as I can tell.

  • Yeah, I already got it, that this is impossible. Yet, we think there is another way to do it. We are using custom controller for this object, so maybe we can pass all parameters, that are set in the ocntroller to the button, where we are calling controller class with nooverride=1 parameter. Should it work? Currently, I'm missing some parameters, that are set in controller, on my button. – J. Mark Sep 12 '18 at 15:32
  • @J.Mark I'm not sure I understand the question, but it sounds like it might work.[ – sfdcfox Sep 12 '18 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.