Help me turn this automation into an action loop instead

Hi all,

I am currently trying to create a cleanup mechanism for my app, and have initially gone the route of automations, but it takes too long to update and has many errors.  So, I am wondering if a loop might be a quicker solution, but I am not too sure on how to set it up for my current situation.  

Here is my table structure:
Tasks - The main table
Task Items - Child record of Tasks
Items - List of Items that is referenced in Task Items.  This table holds a Qty of Items that are currently needed.

The idea of my app is this.  When a Task is created, and a variable number of Task Items are added to it, an automation runs and determines if those Items are greater than any other of the same Items on other Tasks.  If it is greater, it updates the Items table with the Qty.  All of that works fine, but I need a solution for when I need to delete a Task and its associated Task Items.  When a task is deleted, I need it to determine if there are other tasks that have that item, and if so, update the Items table with the next highest Task Item.  If not, it zeroes out the Qty on the Items table for that Item.  After all this is done, delete the task.

As I mentioned above, I cobbled together a really clunky  version using automations, but I am not liking this method.  The way I did it was by creating an action on Tasks, that then sets a flag on a column on Tasks.  Then I created an automation on Task Items that searches for that flag, and uses branching to determine if there other Tasks that have that Item.  Depending on the result, another action is fired that either updates the quantity or zeroes it out on the Items table.  Lastly, it deletes that Task Item row, and flags another column on the Task table with the current number of Task Items for that Task.  When that count is 0, the Task table fires off an automation that deletes the Task row.

Anyone have any ideas to do this with looping actions, or do you have suggestions on how to streamline this.  It is definitely not elegant, and I am not exactly a pro, so any thoughts on how to best approach this would be great.

0 1 59
1 REPLY 1

If a Bot takes too long, I wouldn't try to do it as an action loop. I'd suggest looking into using the API.

Top Labels in this Space