In this post we will learn how to send file attachments over to Salesforce and then publish / relate them to particular records.

Create a new form

On your FormCrafts dashboard click on New Form. This will open a popup dialog where you can choose to start from a scratch, select a template, or duplicate an existing form. For this tutorial we would select Blank Form. On the next screen enter the form name and press Enter.

We now have to add fields to our form. Using the Add Field button on the top-right corner of the screen add the following fields to your form:

  1. A one line input field. Label this one What is your last name?
  2. An email field. Label this one What is your email?
  3. Add a file upload field. Label this Upload a file.

Connect Salesforce

Click on the Salesforce button on the top-left corner of the screen to open the Salesforce sidebar. Now click Connect to connect your organization.

Map Fields

This will be done in three steps.

  1. Create a new contact in Salesforce.
  2. Create a new file in Salesforce.
  3. Associate the file record with the contact record.

Create Contact record

Go to the Records tab and click on Add Action. Select Contact under (select object). Select What is your last name? under (select) and Last Name under (Salesforce field). Click on Add. Follow the same step and map the What is your email? field to Email.

Here is our field mapping:

Salesforce field mapping for the Contact object
Salesforce field mapping for the Contact object

Create Content version

The file object we would attach to our contact record is called Content Version in Salesforce. On the same Records tab add another action, and select the object as Content Version this time. Click on (select) and pick the file upload field labelled Upload a file. Under (Salesforce field) pick Version Data. Click on Add.

There are other fields and mappings you can add to this object but the only one required right now is the Version Data.

Associating the two

Under Create a Content Version you will notice another option: dependent on. Select SF Contact 1 here. This effectively means that creating a Content Version record is dependent on creating the contact record first. If the contact record creation fails, we also don't want to create the file.

The last step is to associate the Content Version object with the Contact record. Under (select) pick SF Contact 1 and under (Salesforce field) pick First Publish Location ID. Click on Add.

Here is our final field mapping now:

Field mapping for the Contact and Content Version objects
Field mapping for the Contact and Content Version objects

Our form is ready. Click on Preview (top-right) and give it a try. Attached files should appear on the Contact's page under Attachments.

File attachments in Salesforce on the Contact record page
File attachments in Salesforce on the Contact record page