Now that your flow has the logic to decide between two paths, let’s build those two paths. First, build the path for the default Create New outcome, which contains only one element.
- Locate the text reading Create New, and click the first Add Element button directly below it. The position should be between Update or Create and End (Create New)
- Select Create Records from the menu.
- In the New Create Records window, enter these values
Field |
Value |
Label |
Create Contact |
API Name |
Create_Contact |
Record |
{!contact} |
- Activate the Done button.
- Verify that the newly added element is connected correctly to the Create New outcome path.
- Activate the Save button.
Now the flow can create a contact record when the Decision element executes and takes the Create New outcome’s path.
Let’s build the path for the Update Existing outcome. First, you need to get the record ID of the existing contact into the contact record variable.
- Locate the text Update Existing near the bottom of the page below the decision element. Click the Add Element button below it.
- Choose Assignment from the menu.
- In the New Assignment window, enter these values.
Field |
Value |
Label |
Set Contact ID |
API Name |
Set_Contact_ID |
- Under the Set Variable Values heading, enter these values.
Variable |
Operator |
Value |
{!contact.Id} |
Equals |
{!Find_a_Match.Id} |
- Simply TAB out of the field list after pasting the value from above.
- Activate the Done button.
- Verify that Set Contact ID is located below Update Existing under the Update or Create? decision element on the canvas.
- Activate the Save button.
Now that the contact record variable contains the record ID of the matching contact, you can reference that contact record variable in an Update Records element.
- On the canvas below the Elements heading, locate the Assignment Element, Set Contact ID button. Activate the Add Element button below it.
- Choose Update Records from the menu.
- In the New Update Records window, enter these values.
Field |
Value |
Label |
Update Contact |
API Name |
Update_Contact |
Record or Record Collection |
{!contact} |
- Activate the Done button.
- Verify that Set Contact ID is located above Update Contact on the canvas.
- Activate the Save button.
You’re all done building the flow! You can run the flow and confirm that contacts in your org are created or updated. If you’re feeling adventurous, click Debug and then Run to see the details of what your flow does as it runs.
Click to return to Trailhead to verify this step.