Published on
SalesForce is a widely used Customer Relationship Manager (CRM) typically used for tracking and following up on customer leads. If you use SalesForce then it can be useful to be able to send data from a ChronoForm directly to SalesForce where it can be included into your tracking system. This FAQ describes how to set up a simple contact form transfer.
You will need access to a SalesForce account to follow this FAQ; you can get a free Developer account, and access technical documents here.
The simplest way to get the necessary list of inputs for a web form is to create the form in SafesForce using their Web-to-Lead form builder. See the documentation here for how to do this.
Note to third-party developers: if the ChronoForm uses inputs that aren't standard SalesForce Lead inputs then you can add them as new Custom Fields in SalesForce and include them in the Web-to_Lead form.
When you have created your Web-to-Lead form you will be able to access the form HTML which will looks something like this example:
<!-- ---------------------------------------------------------------------- --> <!-- NOTE: Please add the following <META> element to your page <HEAD>. --> <!-- If necessary, please modify the charset parameter to specify the --> <!-- character set of your HTML page. --> <!-- ---------------------------------------------------------------------- --> <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"> <!-- ---------------------------------------------------------------------- --> <!-- NOTE: Please add the following <FORM> element to your page. --> <!-- ---------------------------------------------------------------------- --> <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST"> <input type=hidden name="oid" value="00xx0000000xxxx"> <input type=hidden name="retURL" value="http://client_domain.com"> <!-- ---------------------------------------------------------------------- --> <!-- NOTE: These fields are optional debugging elements. Please uncomment --> <!-- these lines if you wish to test in debug mode. --> <!-- <input type="hidden" name="debug" value=1> --> <!-- <input type="hidden" name="debugEmail" value="developer@domain.com"> --> <!-- ---------------------------------------------------------------------- --> <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br> <label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br> <label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br> <label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br> <label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br> <label for="country">Country</label><input id="country" maxlength="40" name="country" size="20" type="text" /><br> Comment or Question:<textarea id="00Ni000000aaaaa" name="00Ni000000aaaaa" type="text" wrap="soft"></textarea><br> Terms and Conditions:<input id="00Ni000000aaaaa" name="00Ni0000004aaaaa" type="checkbox" value="1" /><br> <input type="submit" name="submit"> </form>
What we are interested in here are the form action URL and the input names. Extracting these we get:
https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
as the URL and the list of inputs is:
oid retURL debug debugEmail first_name last_name email phone company country 00Ni000000aaaaa 00Ni000000aaaaa
The first two of these identify the SalesForce account; the next two are only used for debugging; the last two are the identifiers for two SalesForce Custom Fields.
To make this work from ChronoForms we can drag a cURL action into the form On Submit event.
In the cURL action add the URL into the Target URL box.
Then add the list of input names into the Params/Fields map box like this:
oid=oid retURL=retURL debug=debug debugEmail=debugEmail first_name=first_name last_name=last_name email=email phone=phone company=company country=country 00Ni000000aaaaa=some_input name 00Ni000000aaaaa=another_input name
The values after the = sign should match the input names in the ChronoForm - here I've assumed that they are mostly the same - but they don't need to be.
Because the standard cURL will only accept values from the $form->data array (and not plain text strings) we have to add the 'fixed' values to the array using a Custom Code action before the cURL action.
You can avoid this step if you use my custom cURL [GH] action which will accept either plain text, or $form->data names in curly brackets e.g. {input_name}.
In the Custom Code action add code like this:
<?php $form->data['oid'] = '00xx0000000xxxx'; $form->data['retURL'] = 'http://client_domain.com'; $form->data['debug'] = '0'; // change to 1 to enable debugging $form->data['debugEmail'] = 'admin@my_domain.com'; ?>
Save and test your form. You should find that when it is submitted a new lead is created in SalesForce with the appropriate values completed.
Comments: