Forum Documentation Showcase Pricing Learn more

Delay action till the previous one is completed

For the sake of simplicity I’ll try to bring my problem to the most basic form.

I have 3 types of things:

  • Document - a thing that has: 1) a field with a Folder (the one it’s in), 2) a field with a Both related to this Document
  • Folder - a thing that has: 1) a field with a list of Documents (the ones inside), 2) a field with a Both related to this Folder
  • Both - a thing that I use to display the two above in one RG; it has: 1) a field Folder that defines the represented Folder, 2) a field Document that defines the represented Document, 3) a field ParentBoth that represents the Both it’s inside of.

I want to make a workflow that deletes all Documents and Folders that are inside a Folder a user deletes.

Right now my workflow looks like this:

  1. Button “Delete” in my RG is clicked.
  2. Delete the Folder or Document related to the Both.
  3. Delete the Both.
  4. Delete a list of Boths - Do search for Boths that have have no ParentBoth
  5. Delete a list of Folders - Do search for Folders that have have no Both related
  6. Delete a list of Documents - Do search for Documents that have have no Both related

Results:

  1. The Folder and it’s Both are deleted. Success.
  2. All Boths that were “inside” are deleted. Great.
  3. No Folder or Document that was inside is deleted. And it’s despite I can see in the section “App data” that they have no Both related!
  4. Only when I delete another, totally unrelated Folder that those things are deleted properly.

I believe here’s a problem with timing - deletion takes more than bubble needs to go to the next action. Is there a way to overcome it? Delay the next action till the previous is performed?

Would love to hear your thoughts. Thanks in advance!

1 Like

Hi,
perform an action only after completing the previous one - I’m not sure that this is possible.
have ideas hopefully help

  1. try to use pauses between actions, sometimes this helps to fix the timing problem
  2. divide the deletion process into several different events - custom events and call them in turn.
2 Likes

Yes to both suggestions. But #2 is most reliable

1 Like

Thanks for suggestions :slight_smile:

I tried to make it work with scheduled events but it got me only to the point, where things 1 level below are deleted.
That’s some progress but…, if I have a Document in a Folder in a Folder, then deleting the highest level Folder doesn’t delete the Document.

Here’s my workflow with a conditional loop:



Are such recursive loops “forbidden” by Bubble? Or what may be the problem here?

Btw, to make the names on the screenshots clear:

  • NamingTemplate is Document
  • Category is Folder
  • Category/Template is Both

@robert and @jennifervasilenko, I’ve run into similar scenarios where it’s important that each subsequent step waits until the previous step has finished. The only way I’ve been able to make that work reliably is to have buttons for each step that also prevent the other buttons from being active until the previous step has finished.

Is there a more user-friendly way? It’s definitely not professional-looking.

Thanks

Did you consider reversing the order of deletion? Delete the document first, then the folder.

Yes, there are better ways. If something is dependent on another thing happening first (i.e. Step 1 before Step 2, and so on), then break out your workflow into separate workflows for each step, where the final action in the workflow triggers the next workflow (or better yet, schedules the next workflow with a 0.2 second delay).

No, I don’t see any easy way to do it.
I don’t store in a Folder’s field every single thing that’s inside - only the first children. I would first need to recursively find the lowest level child and move upward but there may be many nested folders on different levels so it seems to be a much worse approach.

As I see it, deleting a parent and searching for things that have no parent (but should) is a way clearer.

Nonetheless, why would it matter?

Edit:
I’d like to point out that I set 5s delay to make sure everything has time to be deleted so I suppose time is not the problem. The only reason I can think of is that Bubble doesn’t allow for creating loops. But is that true?

Perhaps it shouldn’t but according to what you said earlier, it apparently does.

So my suggestion is to simply think about alternative ways to attack the problem.

You can create loops…though I am not the best person to give you advice, as this is relatively advanced.

My app has looped workflows, which @romanmg built for me.

I see, thanks for trying to help me out though :slight_smile:

And good to know loops aren’t the case. Perhaps, I’ve made some logic mistake somewhere.

Btw, is it a regular behavior that when I run the process in the step-by-step debug mode the result of “Delete -> Do search for” is empty, yet I can see in the “App data” section that the things were deleted?
It’s like the action was already performed and the data displayed in the debug window is from the end of the whole process that I view step-by-step.