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.
- On the Create New path, click .
- Click Create Records.
- In the New Create Records window, enter these values.
- Label:
Create Contact
- API Name:
Create_Contact
- How to set record field values: From a Record Variable
- How Many Records to Create: One
- Record: select the contact record variable
- Label:
Your flow canvas should look like this.
- 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.
- On the Update Existing path, click .
- Click Assignment.
- In the New Assignment window, enter these values.
- Label:
Set Contact ID
- API Name:
Set_Contact_ID
- Variable: contact > Contact ID
- Operator: Equals
- Value: Contact from Find a Match > Contact ID
- Label:
- 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.
- After the Set Contact ID element, click .
- Click Update Records.
- In the New Update Records window, enter these values.
- Label:
Update Contact
- API Name:
Update_Contact
- How to Find Records to Update and Set Their Values: Use the IDs and all field values from a record or record collection
- Record or Record Collection: select the contact record variable
- Label:
Your flow canvas should look like this.
- 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.