1. Help
  2. Salesforce
  3. Update records

Update a Record in Salesforce

Introduction

In this tutorial, we will learn how to create a lead generation form which would:

  1. Create a new lead in Salesforce

  2. Update an existing contact in Salesforce, or create a new contact if it doesn’t exist

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. We have a large collection of lead generation form templates that you can use.

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

  1. First name (One line text)
  2. Last name (One line text)
  3. Email (Email)
  4. Company (One line text)
Simple Salesforce contact us 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.

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 lead action

Our action should be Create a Lead.

Use the Field mapping section to map the form fields to Salesforce fields.

Under (Form data) you can use plain text or reference fields using the @ key. We will create the following field mappings:

Salesforce create lead workflow action
Create lead workflow action

Configure the contact action

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

The action now should be Create or update a Contact.

We will use Lookup rules to tell the workflow how to find the contact in Salesforce. If the contact is found the workflow will update the contact record; if not it will create a new contact.

Our rules should look for a contact where either:

  1. The email address is an exact match; or
  2. The first name and last name are an exact match

Then we will use the Field mapping section to map the form fields to Salesforce fields.

Our lookup rules and field mappings will look like this:

Salesforce create or update contact workflow action
Create or update contact workflow action

As you can notice lookup rules in Formcrafts are very powerful and allow using multiple rules, with and / or conditions.

Inner and outer conditions can then be used to create complex rules, like in this example.

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