Forum Academy Marketplace Showcase Pricing Features

Backend workflow works 1 way

I have a list of invoices (separate db type) lines in a data type with a total amount that is being calculated with db trigger.

When I add a line to the list, total is being recalculated automatically. But when I delete the line, db does nothing. I mean if I remove the line from db with a workflow, db will recalculate total. But when i just delete it with a workflow, db doesnt react (checked in logs). Is it a normal way it works or is it a bug?

Really just depends on how you setup the trigger. Most likely it is not configured properly to account for both the adding and removing of data. When using triggers you can use conditionals to get pretty specific on how the data was changed to start the workflow.

If you share screen shots of the setup it will be easy to help isolate what is the issue and/or determine if a Bug is at fault. Likely not a Bug though, because if it were a bug it would likely not work at all.

Thanks for the answer.

Well screenshot may make my question even more complicated :smiley: maybe i better explain it this way:

I’ll make it simpler. I have a db type, lets call it MAIN which has just 2 fields, a list of “INVOICE” and a TOTAL number. every INVOICE is a separate db type and has several text fields and one of them is SUM (which is also a fixed number).
every time i add an INVOICE to MAIN i want backend to sum all SUMs and place result to the TOTALS. I could do that with an ordinary workflow on user’s side, but sometimes i need to remove large lists of INVOICEs so it better stay on backend.

So i did a db trigger that says:

Trigger set to watch for MAIN
Thing to change: MAIN now
TOTAL = invoice line’s SUM:sum

That actually does the job when i add the invoice lines to MAIN. And it does subtract when i remove the line from MAIN. But when i just delete an INVOICE or delete list of INVOICES - this workflow doesn’t do anything.

That is because your Trigger is focused on the Main data type and not the Invoice data type. Can’t expect a Trigger that is set to watch for Main to see a change to a separate data type, which is what your Invoice is, a separate data type. So deleting a separate data type (Invoice) will not trigger a database change set to watch for Main. However, the change to the Field of List of Invoices on Main should still be recognized as a change to the Main data type.

Maybe try to structure another Trigger that uses the conditional

When Main Now List of Invoices is greater than Main Before Changes List of Invoices

And another Trigger that uses the conditional

When Main Now List of Invoices is less than Main Before Changes List of Invoices

This way the triggers are listening for when the list of items count on the Field that is the list of invoices changes. Since deleting an invoice would subsequently remove it from the Field on the Main List of Invoices, it should work.

If it doesn’t send a Bug report to Bubble. I am currently trying to explain to Bubble support that their explanation for how the Trigger Custom workflow when data changes (on page action) doesn’t work properly when you listen for a Field which is a list of things.

Likely the Bug I am experiencing on the page action would be affecting the Backend workflow trigger action as well.

Oh that makes sense. Somehow I thought that if I listen to a parent item it will react on all child changes. That seemed logical to me. Or at least a good option would be to have a tick like “watch child items too” or smth like that to make things easier which bubble is actually aimed at. I will try to do what you said by making a longer workflow that will include all possible changes of child items that take part in the process.

Thank you ))

Well it worked with 3 triggers

One is watching for INVOICE and every time any data changes within an INVOICE it calculates sum of all INVOICES within MAIN and places it to TOTAL. This works with changes within an invoice.

Second is watching for deleted INVOICE (Invoice Now is empty) and and every time INVOICE is deleted, it’s recalculating SUM’s of all invoices and places it to MAIN which is associated with INVOICE before change. That works with single invoice deletion.

Third is watching for INVOICES in case other lists containing this invoice are deleted completely and a list of invoices is deleted. theres more complicated situation there but this makes the trick.

Thank you it was nice suggestion that made me think ))

1 Like