Work with Related Records in Salesforce
Introduction
In this tutorial, we will learn how to use the lookup workflow action to find a related record in Salesforce based on lookup conditions. Our form will:
Lookup a contact based on the email address.
Create a new case in Salesforce, associating it with the found contact.
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:
- Name (One line text)
- Email (Email)
- Comments (Comment)
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.
This will open a popup window where you can connect to your Salesforce organization.
Configure the contact action
Our action should be Lookup a Lead.
Use the Lookup rules section to tell the workflow how to find the contact in Salesforce. We will use the email address to find the contact.
Lookup rules are powerful and flexible. You can use multiple rules, have and / or conditions, and even create groups.
Configure the contact action
In the same workflow, click on Add action again and select Salesforce.
The action now should be Create a Case.
Use the Field mapping section to map the form fields to Salesforce fields as follows:
We have mapped the result of the first workflow action (Salesforce Contact #1) to Contact ID. This will associate the new case with the found contact.
We have also mapped the form fields to the case fields.
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.
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.