1. Help
  2. Salesforce
  3. Attach files

Attach Files to Salesforce Records

Introduction

In this tutorial, we will create a upload document form which will find a contact based on the email, and upload the document (under Notes & Attachments) to the contact record in Salesforce.

Create a new form

On your Formcrafts dashboard click on Add Form → Start from scratch. Enter a Form name and hit enter. This will create a new form.

You can also create a new form by clicking on Add Form → Use a Template and selecting a template. This would allow you to skip this step.

Now add some basic fields to your form using the Add field button on the top-left corner of the form editor:

  1. Your email (Email)
  2. File upload (File upload)
Upload document to contact record form

Create a workflow

Click on the Workflows button on the top-left corner of the form editor, and then click on the Add workflow button.

Now edit the new workflow, and click on Add action. Under (select action) find Salesforce, and click on Connect to Salesforce.

Connect to Salesforce organization

This will open a popup window where you can connect to your Salesforce organization.

Configure the lookup contact action

In this action we will simply lookup the contact record based on the email.

Our action should look like this:

Salesforce lookup contact workflow
Lookup contact workflow

Our lookup rule says that we should find a contact where the Email (in Salesforce) is an exact match to the Your email field in the form.

Notice the Salesforce Contact #1. The result of this lookup is now stored in a variable called Salesforce Contact #1, which we will use in the next action.

Configure the content version action

In the same workflow, click on Add action again and select Salesforce.

The action should be Create a Content Version.

Our Field mapping should be as follows:

Salesforce create file workflow action
Create file workflow action

We have mapped the File upload field in the form to Version Data. This is the actual file (or multiple files) that will be uploaded to Salesforce.

We have mapped Salesforce Contact #1 to First Published Location ID. This is the contact record where the file will be uploaded to.

Save and test

Click on the Preview button on the top-right corner of the form editor, and submit the form to test the workflow.

Formcrafts keeps a record of all successful and failed workflows which you can view using the Logs button on the top-left corner of the form editor.

Learn more about Workflow logs.

Workflow logs panel in Formcrafts

Notes

Conditional workflows

By default the Salesforce action(s) is triggered on each form submit. We can add conditions to our workflow to trigger the action(s) only when certain conditions are met. Edit your workflow and click on Add condition. Here you can add conditions, or even create condition groups.

Workflow with a condition
Making workflows conditional