Backend workflow trigger when a thing changes but not a new thing

Hey Fellow Bubblers,

I have an external database I need to keep in sync with a few values. I have an “update database” workflow to handle the Bubble data but I’ve made the assumption that a trigger on a change event would be cleaner (and safer) to synchronise the 2 fields I need to update on the second database. (if you want to school me on why thats wrong - I welcome any advise)

My BE workflow looks like this - Im updating a DepotPrefix and a DepotName

Im assuming this would normally trigger even if a new depot was created and I have a separate process for that to capture Foreign Keys in the other database so this only needs to trigger on a change. Hence the check for not empty.
My questions are

  • Is there a better approach?
  • Should I just trigger from the workflow?
    *When handling deletes I was going to use another workflow will this trigger on a delete as well? (in which case it sounds like workflows would be cleaner)

Thanks in advance :slight_smile:

Hey @johnnyweb. Database triggers can work for new records. I prefer to have “thing before change is empty” condition on the database triggers.

They have become reliable but there might be some cases when they MAY not trigger. I have personally not come across any instance, but I have heard a few folks write about it in the past.

1 Like

Thanks for responding @sharma.himanshu0608 :slight_smile:

I did a bit of reading and coding in-between posting this. Triggers seem most useful when you could potential change data in a number of places and it saves you from having to update every workflow. Overhead doesn’t seem that high either as Bubble checks for triggers with every change to a thing.

one thing I found was boolean changes can’t be monitored with a BE trigger (thing before change doesn’t work) so you need to do a workflow trigger on updates to booleans.

I ended up doing a blend of database triggers for new records (which also meant it triggered when I did a bulk upload from a CSV file) , and workflow triggers for updates which had the booleans.