Handling null values when searching fields in Zapier workflows

I’m working on a Zapier automation that connects my PostgreSQL database with Airtable. When a record gets created or updated in postgres, I want to sync it to airtable. The tricky part is that I have two identifier fields I need to check. The first one (let’s call it backup_id) might be empty or null sometimes. The second field (main_id) always has a value. Right now my zap fails when it tries to search using the backup_id field if that field is null. This prevents it from moving on to search with the main_id field. I need to figure out how to make zapier skip the first search step when backup_id is null, so it can proceed directly to searching with main_id instead. Has anyone dealt with conditional searches in zapier where you need to handle potentially empty fields?

I had a similar postgres-airtable sync issue and solved it with a JavaScript Code step that handles the null checking upfront. I wrote a simple script that checks both backup_id and main_id fields, then spits out a clean search parameter for the Airtable search. The script checks if backup_id exists and has content - if not, it defaults to main_id. No need for multiple paths or complex filtering. You get one consistent output no matter which field has the actual data, and your search action never gets null values. Just watch out for different null types since postgres can send null, empty strings, or undefined depending on how your trigger’s set up.

i also do the same with formatter steps. just insert a formatter before the search to check for backup_id, and based on that output, you can move forward or skip to main_id. def helps with empty fields from postgres.

I encountered a similar challenge when automating between PostgreSQL and Airtable. The solution I found effective was to implement a Filter step in your Zap that verifies the existence of backup_id. If this field has a valid value, the Zap can proceed as usual. If backup_id is null, you can utilize Zapier’s Paths feature to divert the process and perform the search using main_id instead. This method simplifies the workflow and ensures that no searches are attempted with invalid identifiers. Ensure thorough testing of your conditions, as null values can vary in behavior based on the data sent from your PostgreSQL trigger.

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