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
digitalpixmandigitalpixman 

Passing Multi-Select Picklist in S-Control

How do you pass values of a multi-select pick list in a basic S-Control?  Here's my S-Contol:

/a0A/e?CF00N60000001Uy6X={!SessionTEST__c.Client__c}&CF00N60000001UxIh={!SessionTEST__c.Opportunity__c}&00N60000001Uxyd="1"&00N60000001UxyY={!SessionTEST__c.Pose__c}

The code in red is refferences a multi-select picklist, and the values are displayed in the resulting URL:

https://na4.salesforce.com/a0A/e?CF00N60000001Uy6X=Blue+Mountain+Middle+School&CF00N60000001UxIh=Blue+Mountain+Middle+School+Test+Fall+Portaits&00N60000001Uxyd=1&00N60000001UxyY=Puzzle%3BFamily

However, the values "Puzzle" and "Family" are not written to the field.

What am I doing wrong?
jhennyjhenny

Just had this problem as well - %3B is url encode for ";", however, the page will only pick up the first value.

To fix, need to check for every value avail in the multi-select & include a param for every value selected. For Example:

 

 

/a0A/e?CF00N60000001Uy6X={!SessionTEST__c.Client__c}&CF00N60000001UxIh={!SessionTEST__c.Opportunity__c}&00N60000001Uxyd="1"&00N60000001UxyY={!IF(INCLUDES(SessionTEST__c.Pose__c, "Puzzle"),"Puzzle","")}&00N60000001UxyY={!IF(INCLUDES(SessionTEST__c.Pose__c, "Family"),"Family","")}&00N60000001UxyY={!IF(INCLUDES(SessionTEST__c.Pose__c, "OtherVal"),"OtherVal","")}

 

 

Obviously not ideal as this doesnt scale automatically if you make adjustments to the multi-select,

but best i can come up with.

Message Edited by jhenny on 05-19-2009 12:14 PM
RedtagRedtag

Jhenny,

 

I have a similar problem and after searching I came across an S-Control that is meant to loop through the multi-picklist values and format them in the URL. However, it all works except for the multipicklist formatting. Essentially what I'm doing is creating a list button on Account Opportunity that is used to create a Contract. The button is controlled by an S-control. Can you, or anyone else see what is wrong with the attached code. From various postings I'd say this will prove useful to many people if it can be made to work:

 

 

<html>
<head>
<title></title>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>

<script>
var FromPickListField = escape("{!Opportunity.Service_Levels__c}");
var ToPickListFieldName ="00N20000001q7gW";

var pairs = FromPickListField.split(";");

var Fields = ""

for (var i=0;i<pairs.length;i++)

{
var ThisValue = pairs[i]

Fields = Fields + ToPickListFieldName+ "=" + ThisValue + "&"
}


var URL="/800/e?retURL=%2F{!Opportunity.Id}&ctrc7_lkid={!Account.Id}&ctrc7={!Account.Name}&CF00N20000001q2lR_lkid={!Opportunity.Id}&CF00N20000001q2lR={!Opportunity.Name}&ctrc15=Draft&" + Fields

URL = URL + "&" + Fields
parent.frames.location.replace(URL);
</script>
</head>

 

 

 

Message Edited by Redtag on 06-15-2009 10:13 PM
RedtagRedtag

I changed one line to remove the escape function and it works fine now.

 

<html> <head> <title></title> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/10.0/connection.js"></script> <script> var FromPickListField = "{!Opportunity.Service_Levels__c}"; var ToPickListFieldName ="00N20000001q7gW"; var pairs = FromPickListField.split(";"); var Fields = "" for (var i=0;i<pairs.length;i++) { var ThisValue = pairs[i] Fields = Fields + ToPickListFieldName+ "=" + ThisValue + "&" } var URL="/800/e?retURL=%2F{!Opportunity.Id}&ctrc7_lkid={!Account.Id}&ctrc7={!Account.Name}&CF00N20000001q2lR_lkid={!Opportunity.Id}&CF00N20000001q2lR={!Opportunity.Name}&ctrc15=Draft&" + Fields URL = URL + "&" + Fields parent.frames.location.replace(URL); </script> </head>

 

 

 

BillAtParBillAtPar

I'm looking for a custom button or s-control that will select all of the items in a dependent picklist when the user clicks on the button. Your example seems to do what I'm looking for.

 

How would I implement this on a SF page? I have absolutely no experience in SF programming, but I do know javascript, html, etc.

RedtagRedtag

BillAtPar,

 

 When you say select all the items in the picklist, do you mean select the values chosen by the user already and then  pass these values onto another field? Because that is what the code in this post does. I have a custom button that uses the S-Control to create a new Contract from an Opportunity record. Upon clicking the button, the user is taken to the Contract edit page and several fields, including one multipicklist, are filled in with values from the Opportunity page.

 

The code will work with any picklist field with minor modifications.   You'll need to get the field ids for your Taget page field to map the picklist values  from you Source Page field.Use these values to modify your url string in the code.

 

Steve

 

BillAtParBillAtPar

"When you say select all the items in the picklist, do you mean select the values chosen by the user already and then  pass these values onto another field?"

 

 

No, that's not what I meant. 

 

The behavior of the button would be the same as if the user manually selected all items in the picklist and then clicked on the picklist > button. In other words, the button would do the selecting of the items for the user.

 

We want to do this to insure that all items in the picklist are always selected. I understand that this could probably be achieved with validation code, but I have been asked to provide this functionality by using a button.

 

RedtagRedtag
Not sure if this will work but I think you have to send the values to the picklist_selected field which will be something like 00N20000001q7gW_selected (look at the source code of the edit page to get the correct Id for the field). This would become your ToPicklistField variable. So when the user clicks on the button the S-Control loops through the available value in 00N20000001q7gW_unselected  and then your url code would insert the values into the 00N20000001q7gW_selected field.
BillAtParBillAtPar

Steve, Thank you for your help.

 

As I mentioned, I have no experience with S-controls at all. Can you recommend a good source for a beginner's tutorial?

kshannonkshannon
I am also new to this development and realize that S-Controls will no longer be used soon. Can anyone point in the direction of doing this via VFPage?