Multiple select field not submiting fine to SF with CURL

Kinaski 17 Jun, 2009
Hi again,

I hope this wil be my last question for today. Now when I have my forms setup fine and they submit data to Salesforce,email, and DB just fine, I got one more problem left.

I have a multiple select field in one of my forms which was created wityh salesforce. the code is like this :

<select  id="00N20000001qBg5" multiple="multiple" name="00N20000001qBg5" title="Email Service Interest">


Since I could use my custom field names in the forms and use the original in the Curl params section, then I changed the names something like : name="my_m_select_field[]" and the form submits just fine (multiple selections) in the DB and in the emails sent.

But what I get after submit to Salesforce is simply the string "Array" without any of the selected fields:


&00N20000001qBg5=Array&data&data


Please anyone anything?

Thanx a million!
Kinaski 17 Jun, 2009
Hi

I just found an old post with similar problem as I have now: http://chronoengine.com/forums.html?cont=posts&f=2&t=11880&p=19379&hilit=salesforce#p19379

Anyone has any clue what should I do with imploding of the array, and where to put that code (CURL plugin?)?

Otherwise as for as I know salesforce requires the vales outputted like this (caught this with Live headers extension for firefox, when I submitted the raw html form creted in SF):


&00N20000001qBg5=My+First+Option&00N20000001qBg5=My+Second+Option&00N20000001qBg5=My+Third+Option
GreyHead 18 Jun, 2009
Hi Kinaski,

I'm not certain of the sequences here, the first thing to test is to set "ChronoForms handle my posted arrays:" to Yes (in the General Tab in current releases). This may or may not solve the problem, I suspect that it won't but please test.

If it doesn't then we'll need to find a way to handle an array response in the plugin - this probably will need some extra code in the plugin and I'm not sure how to handle it right now.

Are you sure that SalesForce accepts those URLs with the same parameter name repeated identically - that makes it easier?

Bob
Kinaski 18 Jun, 2009
Hi Bob thanx for the replay!

Well I tried the both settings ther yes/no ChronoForms handle my posted arrays. But whatever I choose for the multiple select I got this when the debugger is turned on:

00N20000001qBg5=Array


Yes I'm pretty sure SF receives the url with the same parameter repeated for as much times as I have fields selected in the multi select. The html form created in SF just outputs those urls.

Thanks

Z
GreyHead 18 Jun, 2009
Hi Kinaski,

Ok - I'll try and write a little fix for that.

Bob

PS Oh - looks like this was my 8,000th post here !
Kinaski 18 Jun, 2009
Hi Bob, you're great you know!

Well, I'll consider your answer as a reward for me for your 8000'th post🙂 Congratulations!

Anyway, I'm thinking all this morning how to change the array returned by 00N20000001qBg5[] to be acceptable by salesforce but no luck yet.😟
GreyHead 18 Jun, 2009
Hi Kinaski,

Please will you test if this syntax will work
&00N20000001qBg5=My+First+Option|My+Second+Option|My+Third+Option
It's a convention for multiple values that works in several places. But I don't know if SalesForce support it. I found the SalesForce guide "BUILDING SALESFORCE CUSTOM LINKS" but it doesn't mention multiple values :-(

There are problems hacking the plugin as it build the parameters in an array and any attempt to repeat parameter names just means that the previous one gets over-written.

Bob
Kinaski 18 Jun, 2009
I'm not sure how I can check this but I was messing with this inserted into 'Extra before CURL code':


<?php
JRequest::setVar('00N20000001noip', implode('00N20000001noip=', JRequest::getVar('00N20000001noip')));
?>


But Still no results in SF. I receive this:


myFirstFieldValue00N20000001noi


Maybe my efforts are naive?

Anyway, thanks!
Kinaski 18 Jun, 2009
Tried to use this per your reccomendation:


<?php
JRequest::setVar('00N20000001noip', implode('|', JRequest::getVar('00N20000001noip')));
?>


But in the debug I receive:


00N20000001noip=myFirstFieldValue%7CmySecondFieldValue%7CmyThirdFieldValue


And in salesforce I got this cut off :


myFirstFieldValue|mySecondField
Kinaski 18 Jun, 2009
Any other ideas?

Thanx
GreyHead 18 Jun, 2009
Hi Kinaski,

This has to be possible . . . but how? I'm scratching my head but without success so far.

The best I can come up with is to hand code the cURL and not use the plugin :-(

Bob
Kinaski 18 Jun, 2009
Yeah I tried that too but I just got the same result in SF. I used:


<?php
// SF Org Id.
$oid = "00D20000000agdfrt2";

// Make sure cURL is enabled
if (!function_exists('curl_init')) {
	error("Curl is not setup on this PHP server and is 
    required for this script");
}

if (isset($_POST)) {
	
if (count($_POST) == 0) exit("Error.  No data was passed
     to this script.");
	
// variable to hold cleaned up a version of $_POST data
$cleanPOST = array();	

// Loop through the $_POST data and process it
foreach ($_POST as $key=>$value){
 $cleanPOST[stripslashes($key)] = stripslashes($value);
}

// Add the Org ID
$cleanPOST["oid"] = $oid;
		
	
} else {
 exit("Error.  No data was passed to this script.");
}

// Create a new cURL resource
$ch = curl_init();	

if (curl_error($ch) != "") {
    echo "Error: $error\n";
}
		
// Point to the Salesforce Web to Lead page
curl_setopt($ch, CURLOPT_URL, 
"https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8");
		
// Set the method to POST
curl_setopt($ch, CURLOPT_POST, 1);
		
// Pass POST data
curl_setopt(
$ch, CURLOPT_POSTFIELDS, http_build_query($cleanPOST));
		
curl_exec($ch); // Post to Salesforce
curl_close($ch); // close cURL resource


?>


And I got this in SF:

myFirstFieldValue,mySecondFiel


Again cut off in the middle of "mySecondFiel"😟

Cmon.. I know I'm close/...
Kinaski 18 Jun, 2009
I just found this post in salesforce: http://community.salesforce.com/sforce/board/message?message.uid=28808

The Web-To-Lead servlet interpets this as a single value and receives:

myfield=value1,value2,value3

(You'll see this if you send a hidden field with the name debug and a value of 1)

SFDC doesn't recognize the comma as a delimiter and so you don't get what you expect. What makes it even more confusing is that the multipicklist values in your SFDC app display delimited by semi-colons!

Instead you need to send over:

myfield=value1

myfield=value2

myfield=value3

This did the trick. So whenever I encounter a multipicklist I just loop through the comma delimited values and send the values individually.

Hope that helps!



Any clue on how I could send this values individually?

Thanks
GreyHead 19 Jun, 2009
Hi Kinaski,

Stil no new ideas - except maybe to ask SalesForce to adopt a few common standards.

Bob
Kinaski 19 Jun, 2009
Thanks again

Whatever I think I use a simple html SF form in the article for this and skip th Chronoforms for now.

Z
GreyHead 19 Jun, 2009
Hi Kinaski,

Sorry not to fix this one for you.

Bob
carolynr 16 Dec, 2010
Has anyone ever found a solution to this problem that works within Chronoforms? I'm really new to all this, definitely not a programmer by any stretch of the imagination but I've gotten so far as to get the web-to-lead form from Salesforce and re-created it in Chronoforms (I read that I shouldn't just post the plain HTML in a wrapper or something because then the Salesforce Organization ID would be visible), and everything except the multi-select picklist gets transferred properly to Salesforce (it just appears as "Array" on the Lead form). I don't want to give up now! Can anyone help or point me in the right direction?

Thank you!
GreyHead 16 Dec, 2010
Hi carolynr,

There's a problem with the current version of the cURL plug-in. It doesn't handles array results properly. There is a modified version in the forums that does better.

Do you know what format SalesForce expects this data in? Is it still the repeated parameter format? param=value1¶m=value2¶m=value3 . . .

Bob
carolynr 17 Dec, 2010
Okay thank you, I'll look around for the modified version of the plug-in... hopefully I'll be able to figure out what to do with it once I find it! I don't know exactly what format Salesforce wants the data in, but I did find this post about splitting the values in the POST string (not that I really know what that means): http://boards.developerforce.com/t5/Perl-PHP-Python-Ruby-Development/Multiple-SELECT-picklist-to-Web-to-Lead/m-p/139228 . Here is the other post that is referenced: http://boards.developerforce.com/t5/NET-Development/web-to-lead-picklist-multiple-values/m-p/67428#M5902
Thanks a million-
Carolyn
This topic is locked and no more replies can be posted.