Backend workflow help

Hey,

I have 3 Data Types:

  1. Folder with 2 fields
  • Name (text)
  • Documents (list of Documents)

  1. Document
  • Name (text)
  • Files (list of Files)

  1. File
  • Name (text)
  • File (file)

So, each Folder can contain a list of Documents. And each Document can contain a list of Files.

When a user deletes a Folder, I schedule backend-workflow-1 for Current Date & Time with only 1 parameter: Key = folder type folder-parameter

Inside backend-workflow-1, there are the following actions:

  1. I schedule delete-files (recursive backend workflow) for Current Date & Time with 1 parameter:
  • Files (type File and it is a list/array) = folder-parameter´s Document´s File´s. That evaluates to all Files of all Documents of that folder-parameter.

  1. I schedule delete-documents (recursive backend workflow) for Current Date & Time + 4 days (for not exceeding my capacity and have time to delete first all the Files) with 1 parameter:
  • Documents (type Document and it is a list/array) = folder-parameter´s Document´s. That evaluates to all Documents of that folder-parameter.

  1. I schedule delete-folder for Current Date & Time + 1 day with 1 parameter: Key = files type Files and it is a list/array (checked).
  • Folder (type Folder) = folder-parameter´s

My question is, when I schedule delete-documents, that the list of Documents is folder´s Document´s (being folder-parameter´s the key parameter from backend-workflow-1.

What happens when the delete-folder happens before the delete-documents?

Does the list of delete-documents disappears because the Folder does not exists? Or everything is okay because the list of documents was previously captured in backend-workflow-1.

I have this in a live app, but I questioned this after I deployed and don´t know if it´s well structured or can there be some errors.

Thanks in advance :slightly_smiling_face: :computer:

Hey @hacker

Thanks for the post and killer details here. Very helpful in talking through this.

In this case, you should be fine because you’re scheduling the workflow with the list of documents. So at the time the workflow is created, it has the list of documents it’s going to run on. If your workflow were being scheduled in a way where as part of the workflow run, it was going to do a search for the documents using the folder, it would have no way to locate them and therefore the action wouldn’t run on anything.

Keep in mind, you can get creative here with each workflow scheduling the next instead of having to schedule them all upfront. In this case, the delete files workflow would also schedule the delete documents workflow which would also schedule the delete folder workflow.

And if you want to be on the safe side, one thing you might consider is to have a deleted? yes/no field that you throw to yes for anything you plan to delete. That way, your workflows could simply run searches for any record that’s got a deleted? field set to yes. If you went with this sort of approach, there’s no processing order requirements other than protecting capacity in your app.

If this kicks up any additional questions, don’t hesitate to reach out to us directly at Support@Bubble.io

1 Like

Perfect.

Yes, actually, the example I gave you, it´s not the real thing. The real thing is way more complex with a lot of schedules scheduling others. But this example reflects the question I had.

I also have some sort of field for this.

Thanks for your help, @Andrew.Vernon :grinning: :computer:

This topic was automatically closed after 70 days. New replies are no longer allowed.