Create or Update a Contact
Use a Create Records Element to Create a New Contact
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.
- From the Elements tab in the toolbox, drag Create Records onto the canvas.
- In the New Create Records window, enter these values.
Field Value Label Create Contact API Name Create_Contact Record {!contact} - Click Done.
- Drag the connector node from Update or Create? onto Create Contact. Because the Decision element has multiple outcomes, you’re prompted to choose the outcome to associate with the connector.
- For Outcome, select Create new, and click Done.
- Click Save.
Now the flow can create a contact record when the Decision element executes and takes the Create New outcome’s path.
Use an Assignment Element to Set the Contact ID in the Record Variable
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.
- From the Elements tab in the toolbox, drag Assignment onto the canvas.
- In the New Assignment window, enter these values.
Field Value Label Set Contact ID API Name Set_Contact_ID - In the Set Variable Values section, enter these values.
Variable Operator Value {!contact.Id} Equals {!Find_a_Match.Id} - Click Done.
- Drag the connector node from Update or Create? onto Set Contact ID. Because the Decision element has only one unused outcome at this point, the connector is automatically associated with the Update Existing outcome.
- Click Save.
Use an Update Records Element to Update an Existing Contact
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.
- From the Elements tab in the toolbox, drag Update Records onto the canvas.
- In the New Update Records window, enter these values.
Field Value Label Update Contact API Name Update_Contact Record or Record Collection {!contact} - Click Done.
- Drag the connector node from Set Contact ID onto Update Contact.
- Click Save.
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.
Remember, you don’t have to understand much at this point. After you complete this project, move on to the Flow Builder module. There you learn about what you did in this project—and much more.