Salesforce Connector Version 2 How To: Merge Multiple Form Fields
One of the most frequent questions we get about Version 2 of the Salesforce Connector is, “How do I merge two form fields into one Salesforce field?” In Version 1, you could simply map two form fields to the desired Salesforce field, and they would show up as a single entry. We abandoned this behavior in Version 2 to provide a more powerful and universal method.
Merging Fields to Salesforce
We’ll assume that you have already selected the object type you need to create in Salesforce, so we’ll skip to selecting the Salesforce field within that object where you want to map the multiple form fields. Select the field from the list, and in the “Get Their Value From:” column, select “a formula.”
You need to know the aliases of the form fields you are merging. You can always check the aliases for your form fields by opening http://app.formassembly.com/forms/definition/FORM_ID (be sure to replace FORM_ID with your form’s ID number). Once you have the aliases, use the following formula:
Click “OK” to finalize the mapping.
This strategy is good for combining separate first and last name fields, or combining a three-field phone number collection into a single field.
You can also use a formula to achieve some simple conditional behavior with your mapping. For example, if you have a conditional field on your FormAssembly form, you may want to send that field to Salesforce when it is filled out, but substitute a different field if it is not filled out. Start the mapping as above, by selecting the Salesforce field to which you wish to map the form responses, and then select “a formula.” In the formula box, use this formula:
@IF(%%tfa_field1%%, %%tfa_field1%%, %%tfa_field2%%)
This formula means, “If tfa_field1 is filled in, send tfa_field1 data, otherwise send tfa_field2 data.” This will prevent error messages that might otherwise occur if you mapped the two fields separately.
For example, see this sample form. This form gives the respondent the option to gift a membership to the sample organization. If the respondent selects “Yes” from “Is this a gift membership,” conditional fields appear to collect the recipient’s first and last name. If these are filled out, a Contact record should be created for the recipient. If the membership is not a gift, the Contact record should be created with the respondent’s answers in “Your Information.”
These formulas are not limited to Salesforce; you can use them with any of the other FormAssembly connectors as well.