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
CandraxCandrax 

Porblem with CURL and multiple select field in WebToLead form

Hi I have a wtl form on my site and I'm using CURL to send the POST data to salesforce.

 

Everything's fine except the problem I got with the multiple select fields in the form.

 

All I receive when form submitted is a simple 'Array' in the multi select field In SF leads. If I remove the '[]' from my select field I just receive the last option selected , anyway that should stay there cos I guess it's needed for the other php rutines with the form data.

 

Any ideas why is this happening, and how can be fixed?

 

Thanx

phpandsfdcphpandsfdc
Sure, just call join(';', $arr) on the array before POSTing it to Salesforce.  That's how Salesforce takes multi-select data through the API as well.
joelmanjoelman
Hi.  I'm trying to solve the same problem.  When I post the semicolon-separated array of products, it seems to get cut off, and it doesn't get truly recognized as a semicolon list of products by the sf ui.
Message Edited by joelman on 11-09-2009 10:58 AM
phpandsfdcphpandsfdc
can you post an example string?
joelmanjoelman
The example would be: "MySite (US site);MySite (International site);MyOtherSite", and it gets chopped off at something like "MySite (US site);MySite (Internation".  When I actually use the Web-to-lead html generated by SalesForce, it works just fine.  So somehow I'm not posting the fields correctly.
phpandsfdcphpandsfdc
sounds like a field length issue, your example works perfectly fine for me.
joelmanjoelman

Huh.  Really?  Here's what I'm doing:

 

$params['00N50000001KzeM'] = 'MySite (US site);MySite (International site);MyOtherSite'; $ch = curl_init($sf_url); curl_setopt_array($ch, array( CURLOPT_FOLLOWLOCATION => false, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => http_build_query($params) ) ); $result = trim(curl_exec($ch));

 

The result in sf is cut off as: "MySite (US site);MySite (International s"

 

phpandsfdcphpandsfdc
Yeah, the cutoff is different from what you posted earlier (you were guessing before iirc), I'm now almost positive it's a field length issue, it's cutting off at exactly 40 chars.  Check the field length in Salesforce itself, doesn't look like a cURL issue.
joelmanjoelman
In salesforce, it's a pick-list field.  I don't see anywhere to change the field length there.
phpandsfdcphpandsfdc
huh.  pick-list multi-select you mean, not a regular picklist, right?  If so, I'm at a loss, can't reproduce the issue, and yeah, doesn't appear that there's any way to edit the field length.
joelmanjoelman
Grr ... You wouldn't happen to know if the semicolons are being urlencoded to %3Bs, would you?
phpandsfdcphpandsfdc
nothing good...  You'll need to send the data unencoded, because it'll be expecting the SOAP message as plain, un-urlencoded text.
Candrax1Candrax1

Hi Guys,

 

Please check billkat's post here:

 

http://community.salesforce.com/sforce/board/message?board.id=PerlDevelopment&message.id=4051

 

That's how I solved my curl problem  :)

 

You have to loop through the array and send every option separately.

 

Cheers 

joelmanjoelman

HA!  That did it!  Thanks so much.

 

Joel