You are here:
Use a Form Handler to Update Salesforce Objects with Form Data
Use a form handler to capture data from a form on an external website and use that data to create or update records in Salesforce. Form handlers make it possible to use the existing forms on your site without updating your site to use forms created in Salesforce. When you create a form handler, you specify the field names in your existing form and the Salesforce fields that they map to.
Required Editions
| Available in: Enterprise and Unlimited Editions with Marketing Cloud Growth or Advanced Edition, and Pro Suite Editions. They also apply to these editions when Salesforce Foundations is enabled. Your edition determines the options that you have. |
| User Permissions Needed | |
|---|---|
| To create a form handler: | Marketing Cloud Manager permission set AND Any CMS workspace contributor role |
| To publish a form handler: | Marketing Cloud Manager permission set AND A CMS workspace contributor role of content admin or content manager |
When you create a form handler, you also create a data source in Data 360. This data source stores the data the form captures. Before creating a form handler and a corresponding data source, think about how best to structure the data the form captures. There are two general patterns for designing the data structure: explicit field names and generic field names.
In a data source that uses explicit field names, specify each field name in the data model. This structure is easy to understand, but requires modifying the object every time you add a field. A data model with an explicit structure resembles this example.
| Field Name | Type |
|---|---|
| First Name | Text |
| Last Name | Text |
| Text | |
| Address | Text |
| Occupation | Text |
| ... | ... |
Alternatively, a data source can use generic field names, or more often a combination of explicit and generic field names. This approach provides more flexibility, allowing you to handle new field names without modifying the object. However, generic field names are ambiguous and require using metadata to describe the attributes in the payload. A data model with a generic structure resembles this example.
| Field Name | Type |
|---|---|
| First Name | Text |
| Last Name | Text |
| Text | |
| Attribute1 | Text |
| Attribute2 | Text |
| Attribute3 | Text |
| ... | ... |
Create a Form Handler
- On the Content tab, select a content workspace to create the form handler in.
- Click Add | Content.
- On the Create CMS Content window, select Form Handler, and then click Create.
-
In the top-left corner of the window, next to Untitled, click the pencil icon (
). Enter a name for the form handler.
-
Add a Data Source.
- In the panel on the right, under Data Source, click Add Data Source.
- Enter a name for the data source.
- For Type, select Salesforce Record.
- For Object, select the type of record the form handler operates on. For example, to update Contact records, select Contact.
- Save your changes.
-
Map the form fields.
- From the panel on the left, click a field to capture from the form and drag it to the center of the page. For example, select the Contact object if your form collects information about the user’s First Name, Last Name, or Email address. Repeat this step for every field the form data interacts with.
- In the center of the page, click one of the field names you added. Then, in the panel on the right, enter an external field name. Repeat this step for all selected fields.
The external field name is the link between your website form and Salesforce. It connects each field in your form to the Salesforce field that stores the submitted value. Keep these requirements in mind when specifying the fields to capture:
- The external field name you enter must exactly match the HTML name attribute of the field in your form.
- Date values use the format
YYYY-MM-DD. - Time values use the format
hh:mm:ss. - DateTime values use the format
YYYY-MM-DDTHH:mm:ss.sssZ(ISO 8601 format). - For checkbox values, if the checkbox is selected on the form, Salesforce records it as
truein the object.
- Save your changes.
For information about updating your site to handle form submissions securely, see Developer Documentation: Integrate Form Submissions with the Connect API.
Add Spam Protection to a Form Handler (Optional)
Protect against hacking and spam by adding a hidden honeypot field to your form. When a bot tries to submit a form, it often completes every field in the form, including hidden fields. If you include a honeypot field in your form, the form handler blocks all submissions that include a value in that field.
- From the Spam Protection Fields panel, add the Honeypot field.
-
For External Field Name, enter a field name to use for the honeypot.
Tip Bots try to exploit form fields that allow users to enter text freely. They search for fields with generic labels, such ascompany,website, orfax. Enter a name that makes the honeypot field an appealing target, but that doesn’t overlap with the data to capture in the form. Don’t use an obvious name, such ashoneypotordo_not_fill. - In your form’s HTML, add a hidden input field with the matching name attribute.
Automate Actions with a Flow
To automate tasks like creating leads or sending emails after a user submits a form, connect a flow to the form handler. In the Flow section of the form handler, click New Flow to open Flow Builder.
When you create a flow from the form handler page, the external field names you specified are available as resources in the flow. Use the values of these external fields in flow decision steps, to personalize message content, and in other flow actions. Also use these resources to modify any object, not just the object you selected when creating the form handler.
Configure Submission Redirects
In the Submission Redirect section, enter the full URLs to send users to when a form submission succeeds or fails.
Publish the Form Handler
Publish the form handler to generate the code that connects your website form to Salesforce.
- When you’re ready to publish the form and its flow, click Publish.
- Turn on web tracking to monitor user engagement.
After you publish, the form handler generates the code that you use to configure your form to send data to the form handler.
