How to update a record if it exists and create one if it doesn't

  • 8 April 2021
  • 0 replies
  • 334 views
How to update a record if it exists and create one if it doesn't
Userlevel 7
Badge +10

This is one of those things that isn’t necessarily complex, but it’s easier to demonstrate with screenshots than it is to type out instructions.

The Challenge

You want to search for a record (contact, deal, lead, etc) in your app of choice, and if it’s found then you want to update it. If nothing is found, you’d like to create it.

It sounds simple enough to those who are well-versed in Zapier, but it’s not always immediately obvious how to accomplish this.

The Solution

I’ll tackle this in two parts. First, a brief explanation of what we’re going to be building. Next, I’ll get into the nitty gritty details for anyone who still needs it.

The Short Answer

Trigger: Your app of choice
Action: Find/Create (insert your record type here)
Filter: Only continue if the record is found
Action: Update (insert your record type here)

IMPORTANT: In order to do this most efficiently, you’re going to need an action in your app that allows you to find an item and create one if it’s not found. Like these actions in Pipedrive:

 

 

Some apps have a Find action that doesn’t allow you to create an item if nothing is found. In that case, you can either use two Zaps, with a filter in each (one for when something is found, and one for when it isn’t) or use our Paths function (again, one path for when you’ve found something and one for when you haven’t).

ALSO IMPORTANT: You will also need your app to have an Update (insert your record type here) action, since otherwise you won’t be able to do anything once you find your record.

The Longer Answer

In this example I’m going to use the Zapier Chrome extension to trigger my Zap, since it’s an easy way to add data to a few fields and then trigger a Zap. I’ll then use Pipedrive for my action app since I used them as an example above.

Trigger — Zapier’s Chrome Extension

This part isn’t necessarily important to you, aside from knowing that it’s how I’ll be adding data to the fields I then use in my action steps. But, if you haven’t checked out our Chrome extension yet, now’s your chance!

Action — Pipedrive (Find or Create Person)

I’m going to search by Name in Pipedrive, looking for an exact match. I map the first and last name from my trigger step.

I check the box for “Create Pipedrive Person if it doesn’t exist yet?” in order to make sure that if nothing is found, that I create a new person.

I then use the same mapped fields in order to create a person (if none is found).

 

 

Filter (Technically optional)— Only continue if found

You could choose to always update the person, even if you just created them in the previous step, but all these extra tasks can add up if your Zap runs a lot. Instead, you can choose to only continue if the Zap Data Was Found field is TRUE.

mine says FALSE because I created the person while testing the Zap

 

For the condition choose (Boolean) Is true:

 

Action — Pipedrive (Update Person)

This is the part that trips up a lot of people. You can’t choose a person from the dropdown menu, otherwise you’ll always be updating that same person every time the Zap runs. How do we make it dynamic, so we update the person from our search step?

Answer? We use a Custom option:

 

Then we map the ID field from our Find/Create step. It’s almost always going to be a field along the lines of ID:

BONUS TIP: A quick way to know whether you’re mapping the correct field here is to use the dropdown to find the record that’s showing up in Custom, to see what’s under it:

note that 375 shows up as the ID in the screenshot above this one

 

Finally, I’ll map the fields that I want to update if the person is found in Pipedrive:

in my basic example, I’m updating a single field

Wrapping Up

There you have it! That’s how you can update a record in your app if one is found, and create one if nothing is found :)


0 replies

Be the first to reply!

Reply