Error integrating with Salesforce with CF7
-
I’m getting an error integrating with Salesforce with Contact Form 7.
The debug message states:
There was an error when trying to integrate with the 3rd party service {Salesforce} (https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8).
I mapped the contact form fields and added the “oid” that I found in other Salesforce integration code we have. Is there anything else needed for integration? I’m totally new to this.
Thanks,
braymond
-
Anybody?
Sorry, as I’ve mentioned in other support threads you’ll have to post most of the debug email, since it contains all the fields and what was sent, as well as the response from the endpoint. You can either copy it here (redact sensitive info) or send it through my website.
Below is the email from CF7-3rdparty Debug [CF7-3rdparty-debug@sonicsinc.com] titled CF7-3rdParty Integration Failure: Salesforce — with information redacted:
There was an error when trying to integrate with the 3rd party service {Salesforce} (https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8).
**FORM**
Title: Sonics Contact Form English
Intended Recipient: <email address>
Source: http://sonicsinc.com/contact-form-salesforce/**SUBMISSION**
Array
(
[timeout] => 10
[body] => Array
(
[contactJobTitle] => test
[contactFirstName] => test
[contactLastName] => test
[contactCompany] => test
[contactEmail] => <email address>
[contactPhone] => test
[contactCountry] => test
[contactType] =>
[contactMessage] => test
[oid] => <our oid>
))
**RAW RESPONSE**
Array
(
[reason] => Could not locate success clause within response
[safe_message] => Success Clause not found
[clause] => Thank you for your submission. A Sonics representative will follow up with you soon.
[response] =>
)Below is the email from Forms: 3rd Party Integration Debug [Forms3rdPartyIntegration-debug@sonicsinc.com] titled Forms: 3rd Party Integration Debug: Salesforce with information redacted:
*** Service ***
Array
(
[name] => Salesforce
[url] => https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
[forms] => Array
(
[0] => cf7_3862
)[success] => Thank you for your submission. A Sonics representative will follow up with you soon.
[failure] => We’re sorry. There was an error with your contact request.
[timeout] =>
[mapping] => Array
(
[0] => Array
(
[lbl] =>
[src] => name
[3rd] => contactName
)[1] => Array
(
[lbl] =>
[src] => job-title
[3rd] => contactJobTitle
)[1418886179864] => Array
(
[lbl] =>
[src] => first-name
[3rd] => contactFirstName
)[1418886195673] => Array
(
[lbl] =>
[src] => last-name
[3rd] => contactLastName
)[2] => Array
(
[lbl] =>
[src] => company
[3rd] => contactCompany
)[3] => Array
(
[lbl] =>
[src] => email
[3rd] => contactEmail
)[4] => Array
(
[lbl] =>
[src] => phone
[3rd] => contactPhone
)[5] => Array
(
[lbl] =>
[src] => address
[3rd] => contactAddress1
)[6] => Array
(
[lbl] =>
[src] => city
[3rd] => contactCity
)[7] => Array
(
[lbl] =>
[src] => state
[3rd] => contactState
)[8] => Array
(
[lbl] =>
[src] => zip
[3rd] => contactZip
)[9] => Array
(
[lbl] =>
[src] => country
[3rd] => contactCountry
)[10] => Array
(
[lbl] =>
[src] => topic
[3rd] => contactType
)[11] => Array
(
[lbl] =>
[src] => message
[3rd] => contactMessage
)[12] => Array
(
[lbl] => Receive Sonics’ Monthly Newsletter
[src] => checkbox-533
[3rd] =>
)[13] => Array
(
[val] => 1
[lbl] => ID to integrate with Sonics’ Salesforce
[src] => <our oid>
[3rd] => oid
)[1418886214085] => Array
(
[lbl] =>
[src] =>
[3rd] =>
))
[separator] =>
)*** Post (Form) ***
http://sonicsinc.com/contact-form-salesforce/
Array
(
[_wpcf7] => 3862
[_wpcf7_version] => 4.0.2
[_wpcf7_locale] => en_US
[_wpcf7_unit_tag] => wpcf7-f3862-p4704-o1
[_wpnonce] => 858cfbcda4
[first-name] => test
[last-name] => test
[job-title] => test
[company] => test
[email] => <email address>
[phone] => test
[country] => test
[message] => test
[_wpcf7_is_ajax_call] => 1
[topic] => Array
(
[0] =>
)[default:1] => Array
(
[0] =>
))
*** Post (to Service) ***
Array
(
[timeout] => 10
[body] => Array
(
[contactJobTitle] => test
[contactFirstName] => test
[contactLastName] => test
[contactCompany] => test
[contactEmail] => <email address>
[contactPhone] => test
[contactCountry] => test
[contactType] =>
[contactMessage] => test
[oid] => <our oid>
))
*** Response ***
Array
(
[headers] => Array
(
[date] => Fri, 19 Dec 2014 09:52:59 GMT
[set-cookie] => BrowserId=79qr1uT7QGC2dVX79TPR8Q;Path=/;Domain=.salesforce.com;Expires=Tue, 17-Feb-2015 09:52:59 GMT
[expires] => Thu, 01 Jan 1970 00:00:00 GMT
[cache-control] => private,s-maxage=0
[content-type] => text/html;charset=UTF-8
[connection] => close
)[body] =>
[response] => Array
(
[code] => 200
[message] => OK
)[cookies] => Array
(
[0] => WP_Http_Cookie Object
(
[name] => BrowserId
[value] => 79qr1uT7QGC2dVX79TPR8Q
[expires] => 1424166779
[path] => /
[domain] => .salesforce.com
))
[filename] =>
)Sorry for the delay.
Salesforce isn’t returning a useful response, but it looks like nothing is getting sent for
contactType. Looking at the form submission, you’ve submitted an array — is thetopicfield a multiselect with nothing chosen? Multiselect might not be a problem (my plugin can collapse multiple values), but the fact that nothing was selected may be the issue?It is a multiselect with nothing selected – it’s not a mandatory field. I tried a test with an option selected, but it had no effect. Maybe the code below will help? This is the salesforce integration portion of a different form on our site that does work. It was coded by somebody else before I started working on the site. I’ve swapped out identifying information.
/* —————————————————————- */
function add_to_salesforce($name, $email, $company, $city, $state, $zip, $country, $phone, $street, $leadsource, $jobtitle, $description, $contactType) {
// simple way of breaking apart the name
$names = split(” “, $name);//Check to see if cURL is installed …
if (!function_exists(‘curl_init’)) {
die(‘Sorry cURL is not installed!’);
}//set POST variables
$url = ‘https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8’;
$fields = array(
‘first_name’=>urlencode($names[0]),
‘last_name’=>urlencode($names[1]),
‘company’=>urlencode($company),
‘street’=>urlencode($street),
‘city’=>urlencode($city),
‘state’=>urlencode($state),
‘zip’=>urlencode($zip),
‘country’ => urlencode($country),
’email’=>urlencode($email),
‘phone’=>urlencode($phone),
‘description’=>urlencode($description),
‘<digits>’ => ‘Contact form’,
‘<digits>’ => urlencode($leadsource),
‘<digits>’ => urlencode($contactType),
‘title’ => urlencode($jobtitle),
‘oid’ => ‘<digits>’, // id
//’retURL’ => urlencode( get_site_url().’/contact-us’ ), // Don’t need a return URL
‘debug’ => ‘0’,
‘debugEmail’ => urlencode(“<email>”),
);//url-ify the data for the POST
$fields_string = ”;
foreach($fields as $key=>$value) { $fields_string .= $key.’=’.$value.’&’; }
rtrim($fields_string,’&’);//open connection
$ch = curl_init();//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, FALSE);//execute post
$result = curl_exec($ch);//close connection
curl_close($ch);
}add_to_salesforce($contactName,$contactEmail,$contactCompany,$contactCity,$contactState,$contactZip,$contactCountry,$contactPhone,$contactAddress1,’Sonics Website’,$contactJobTitle, $contactMessage,$contactType);
/* —————————————————————- */
Does the above information help at all?
sorry, not ignoring — just need time to look…
Well, if
contactTypeis the issue, then the original code shows it should be mapped to some<digits>instead; so you should be mappingtopicto whatever those digits were. Basically, you should be mapping your CF7 field names to all the keys in the original code’s$fieldsarray.
The topic ‘Error integrating with Salesforce with CF7’ is closed to new replies.