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
FlickerboxRogerFlickerboxRoger 

Sending values from multi select picklist

Hi,
I have a series of checkboxes in a form represented by a single multi-select picklist field in Salesforce. When I submit the lead, it looks like the values are sent as one single value that gets cut off after 40 characters. How can I report each value individually yet have them be part of the same field.

Thanks for any ideas.
Roger

The html:

Code:
* Current Version Control Solution (please select as many as apply):<br />
<input name="choices[]" value="Accurev" type="checkbox"  />&nbsp;Accurev <br>
<input name="choices[]" value="IBM Rational ClearCase" type="checkbox" />&nbsp;IBM Rational ClearCase<br>
<input name="choices[]" value="Perforce" type="checkbox" />&nbsp;Perforce<br>
<input name="choices[]" value="Bitkeeper" type="checkbox" />&nbsp;Bitkeeper<br>

The php:
Code:
$clean['choices'] = $_POST['choices'];
$choices = array();
$choices = $clean['choices'];
if (count($choices) > 0) {  
for ($i=0;$i<count($choices);$i++)
    {  
        $salesforce_data['00N30000001rpAQ'] .= "$choices[$i]";
    }  
}

 



Message Edited by FlickerboxRoger on 02-11-2008 03:35 PM
sf_davesf_dave
hi Flicker,

It is possible to do this, you just need to ensure the values you are sending from your check boxes EXACLY match the possible values in the pick list.  If they do not match the values will not dissapear from the "Available" options and your slightly different value you send will appear as a selected value, even though it is not part of the possible options.

Also note that in the salesforce PHP api picklist values are sent as a single string separated by semi-colons so you need to have a picklist in salesforce, named Options__c, with the optional values:
"Option 1"
"Option 2"

and your check boxes
<input name="options[]" value="Option 1" type="checkbox" />&nbsp;Option 1<br>
<input name="options[]" value="Option 2" type="checkbox" />&nbsp;Option 2<br>

Then in your form handling:
Code:
if (!empty($_POST['options'])
{
    foreach ($_POST['options'] as $option)
    {
        $sforceOptions .= utf8_encode($option.";");
    }
}

$sforceObj->Options__c = $sforceOptions;


NOTE: if your Salesforce picklist options were setup like this:
"Option 1"
"Option 2"

and your check boxes were setup like this:
<input name="options[]" value="Option_1" type="checkbox" />&nbsp;Option 1<br>
<input name="options[]" value="Option_2" type="checkbox" />&nbsp;Option 2<br>

after you sent the data to Salesforce you picklist would show the values:
Option 1
Option 2
as still being selectable and the values
Option_1
Option_2
as being selected.

So as I mentioned, please double check the values in Salesforce and in your web form to ensure it works as intended.

hope that helps
-Dave