I’m working with a Zapier automation that syncs data from Google Sheets to a MySQL database. The workflow has two paths - one creates new records if they don’t exist (working fine), and another updates existing records with new data from the spreadsheet.
The update process works perfectly when replacing existing values with new ones. For example, my database table looks like this:
+----------+----------------+------------------+
| record_id| user_feedback | sheet_source_id |
+----------+----------------+------------------+
| 1001 | positive | 8945623789654321 |
+----------+----------------+------------------+
When the spreadsheet data changes, the MySQL record updates correctly:
+----------+----------------+------------------+
| record_id| user_feedback | sheet_source_id |
+----------+----------------+------------------+
| 1001 | negative | 8945623789654321 |
+----------+----------------+------------------+
However, when a user clears the feedback field in the spreadsheet (leaving it blank), the old value remains in MySQL instead of being cleared:
+----------+----------------+------------------+
| record_id| user_feedback | sheet_source_id |
+----------+----------------+------------------+
| 1001 | negative | 8945623789654321 |
+----------+----------------+------------------+
I need it to clear the field like this:
+----------+----------------+------------------+
| record_id| user_feedback | sheet_source_id |
+----------+----------------+------------------+
| 1001 | | 8945623789654321 |
+----------+----------------+------------------+
After testing and contacting Zapier support, I learned that NULL values get stripped from the Python code step output. My Python code handles empty inputs like this:
# Handle missing input values
def process_input(field):
return source_data.get(field, default_empty)
def map_fields(field_list, mapping_list):
for target, source in zip(mapping_list, field_list):
val = process_input(source)
output_data.update({target: val})
sheet_fields = ['equipment_type', 'start_date', 'end_date', 'task_desc', 'vendor_name', 'status_booked', 'status_confirmed', 'job_number', 'completion_flag', 'estimated_cost', 'invoice_amount', 'invoice_ref', 'booking_ref', 'last_updated', 'feedback_notes']
database_fields = ['equipment', 'from_date', 'to_date', 'description', 'contractor', 'booked', 'confirmed', 'job_id', 'complete', 'est_cost', 'inv_amount', 'inv_number', 'book_ref', 'update_time', 'notes_feedback']
# Process all field mappings
default_empty = None
output_data = {}
map_fields(database_fields, sheet_fields)
final_results.update(output_data)
return final_results
The code runs without errors and updates work for actual values, but when fields are deleted in the sheet, old MySQL values persist. Zapier support confirmed that NULL values are stripped from the Python step output before reaching the MySQL update step.
I tried using empty strings instead of NULL but got the same result. Has anyone found a workaround for this Zapier limitation?