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!
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
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
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
Ok - I'll try and write a little fix for that.
Bob
PS Oh - looks like this was my 8,000th post here !
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.😟
Please will you test if this syntax will work
&00N20000001qBg5=My+First+Option|My+Second+Option|My+Third+OptionIt'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
<?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!
<?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
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
<?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/...
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
Stil no new ideas - except maybe to ask SalesForce to adopt a few common standards.
Bob
Whatever I think I use a simple html SF form in the article for this and skip th Chronoforms for now.
Z
Thank you!
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
Thanks a million-
Carolyn
