Need help with a Workflow triggering logic

Here is a video explaining what I need help with.

I essentially need to figure out the triggering logic of a WF that will allow me to change values in my DB based on one item being removed from the multi drop down.

What change are you trying to make based on the tag being removed? If it’s just the categories list on the parent data type, auto binding will cover it for you.

1 Like

Those tags are connected to an item that has a number value. When a tag is added that item number value is changed.

I want the trigger to know when only one tag is removed so it can edit the number value of the item that belonged to that tag.

Hopefully that makes sense.

Yep, that makes sense. I think the best way to do this is a two-pronged approach.

  1. Make an action on that page that just updates the db whenever a tag is added or removed.
  2. In Backend Workflows, create a Database Trigger event (“A Thing is modified…”). Choose your Line Item data type, and set the “Only when” condition for something like this: “Only when Line Item before change’s Categories:count < Line Item now’s Categories:count”.
  3. Add your logic to update the value of the proper item in your database after that. Something like “Line Item now’s Categories each item’s Amount:sum”

The reason db triggers are so powerful is they capture the value of your object both before and after the change, and let you access those values in the workflow.

Oh so there is a “before changes” logic. I’ll try this and keep you updated! Thanks!

Hopefully this video is not too confusing. I need to also carry over the amounts number to properly modify the data that I want to modify. Any suggestions?

You should have a transaction that contains line items (linked data type) and just remove the line item from the the transaction so the calculation is this transcation line items’s whatever field for the value is:sum - the removed line item’s value, no?

The transaction would have a list of line items by a reference type and just add/remove line items to the transcation. The calculation is a different thing.

If you store the transcation value alone, then just substract the line item’s value from the transaction value

What akamarski said. I was guessing on the data types but now it’s clear that the db trigger should be on the Transaction being modified.

There’s also another approach which is to just update the tags/categories in the database and then calculate the totals for each category at runtime instead of storing a category total in the db. You don’t need any db triggers with that approach. That would also allow you to put time/date filters on it, like “Last 7 Days” or “Last month”.

Basically, wherever you want to display the total, just add a Text with a dynamic value of “Search for Transactions where tags contains ________, each item’s Amount:sum”.

If that’s not clear, I can make a Loom for you.

If you could make a loom that would be great! I believe I understand but I am more of a visual learner so it would help.

Ya I may be able to just delete it. I may be making it harder than it is lol. I just have to double-check to see how I got the database setup.

Edit: So as I slept on it, I realize that I can not just delete it because the line item is connected to the budget. So that is why I just pass a value instead of adding in a list of line items to the transactions.

Here you go!