Integromat duplicate paths

Something that regularly crops up with Integromat is when you search for an existing record in some external service. If the record doesn’t exist, you need to create it. If it does exist, you need to update it. And then in both instances, you need to follow the same set of following actions.

So you end up with a scenario that looks like this:

An Update operation won’t create a missing record, and a Create operation will throw an error if the record already exists. So we need two execution paths.

Notice that you have the same list of actions on each path following after the create/update modules. That duplication isn’t great even on just two branches and two following actions – imagine if you had 3 or more branches, and a long string of actions on each. How maintainable is that? What’s the chance of updating one branch and getting something wrong on another? It also massively increases your testing conditions.

Ideally, Integromat would have the opposite of a Router – a Converger, bringing two or more routes back to a single one. That’s planned (details here) but not yet available.

The link above details some general case workaround strategies, but in the particular update/create case we’re talking about here, there’s a much better method.

Integromat provides for error handling, which can come in handy here – see here for details. Remember that the Create operation will throw an error if the record already exists? We can make use of that.

In the example above, we just go ahead and create the record based on the details in the Google Form. If the record already exists, the module will throw and error and follow the lower error handler route. There, we find the existing object and update it. But how do we get back to the upper route?

That’s where the magic comes in. The “Resume” error handler tells Integromat to resume processing after the failed module, using different outputs to replace the missing outputs of the failed module. You get to specify where those missing outputs come from, as in the example below:

So we’ve now simplified the scenario, saved an operation on the Create path, and made it easier to maintain and test.

The same approach can be used in other cases – all you need is to decide what operation to try first, and what the error handling route will follow.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with
Get started
%d bloggers like this: