Baserow check for records exist/not then update/create

Looking for help designing a wrokflow where i can have two different paths as new records come in i need to search them in the baserow database first and see if they already exist then i will just update them, if they dont then i will create them.

I used the below design of getting all rows from baserow and having my other input node both goes into two combine nodes, where one of them is set to release out the matching records (duplicates-existing record) that goes to update node at the end. while the other combine node releases the non matching records and then i filter the records to pass only the ones that carries fields of my input node and push it to baserow create node.

is there a better way of doing the above scenario… check for record exist or not and then take two different paths of create or update.

below is the workflow:

image

code:

Hi @mibrahim547, as long as your approach works the way it does I’d stick to it.

However, seeing you are looking for an alternative, you could also do the following:

  1. Split your incoming items into batches of 1 using the Split In Batches node
  2. Search for the item using the Row → Get Many operation of the Baserow node with a suitable filter, enabling the “Always Output Data” option to prevent n8n from stopping when it finds no matching row:
  3. Use a Set node after the Baserow node to prevent the input data from getting lost
  4. Close the loop

After the loop you will then be able to add an IF node to check if an existing Baserow row was found or not. This might be easier to read, but that’s a personal preference of course. This is how my example workflow would look like:

You can test this using a Baserow database table looking like so (or by adjusting it to your actual data structure of course):

In the above example, n8n would identify the missing record on the IF node as it should:

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.