# How to Show a Loading Spinner Multiple Looping Backend Workflows Complete

**URL:** <https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084>\
**Category:** Need help\
**Created:** [February 1, 2025, 1:32pm UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084 "2025-02-01T13:32:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregsheen23](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@gregsheen23](https://forum.bubble.io/u/gregsheen23)\
**Post date:** [February 1, 2025, 1:32pm UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/1 "2025-02-01T13:32:50Z")

</div>

Hey everyone,

I’m working on a project in Bubble and need some help with handling a loading spinner while multiple backend workflows are running.

### **What I’m Trying to Achieve**

I have a **button** that triggers a **backend workflow** (let’s call it Workflow A). This workflow then triggers **four additional recursive (looping) backend workflows** (Workflows B, C, D, and E). Each of these recursive workflows **loops through a list** from a JSON and creates items in the database.

I want to **display a loading spinner** while all of these recursive workflows are running and then **hide the spinner** once everything has completed.

I tried implementing a solution where I create a database entry `backend_workflow_log` that is set to `complete` when a workflow finishes. However, this approach doesn’t work as expected because:

1. It will create the `backend_workflow_log` on the first loop of the recursive workflows, rather than wait for the final one to complete.
2. Since the workflows run **asynchronously** , I don’t have a clear way to track when all of them have finished.

**Here’s a simplified version of what is happening:**

- Workflow A takes a JSON file and generates four separate lists.
- Workflows B–E each process one of these lists, looping through their items and creating database entries for each iteration.

It would be great if there is a way of doing this by creating things in the database, like `backend_workflow_log`. But I’m open to suggestions, Thanks!

---

<div class="post-metadata">

**Author:** ![akamarski](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@akamarski](https://forum.bubble.io/u/akamarski)\
**Post date:** [February 1, 2025, 2:24pm UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/2 "2025-02-01T14:24:55Z")

</div>

If you know beforehand how many items will be created, you can show the spinner on button click and hide it once the created items matches the number you already know

---

<div class="post-metadata">

**Author:** ![gregsheen23](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@gregsheen23](https://forum.bubble.io/u/gregsheen23)\
**Post date:** [February 1, 2025, 6:44pm UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/3 "2025-02-01T18:44:49Z")

</div>

No I will not know how many items will be created upfront

---

<div class="post-metadata">

**Author:** ![yannandco](https://avatars.discourse-cdn.com/v4/letter/y/4491bb/32.png) [@yannandco](https://forum.bubble.io/u/yannandco)\
**Post date:** [February 2, 2025, 2:03am UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/4 "2025-02-02T02:03:20Z")

</div>

I also dream of a “call back” step, like I use on Filemaker:  
Create those stuff, when done call this script that shows a nice completion message

---

<div class="post-metadata">

**Author:** ![mitchbaylis](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mitchbaylis/32/122860_2.png) [@mitchbaylis](https://forum.bubble.io/u/mitchbaylis)\
**Post date:** [February 2, 2025, 3:34am UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/5 "2025-02-02T03:34:25Z")

</div>

basically you have to build the logic to track the completions

one way you could do it  
1 - schedule workflow to “initialize” process this then logs the total count and starts the repeater  
2 - repeat to create/edit each thing  
3 - count up on each completion  
4 - force doing the items one after the other instead of concurrently  
5 - have a progress bar on the front end for the user to visualize (requires saving the count and total somewhere)

it there are multiple lists to process then the only way to do it is to force process them one after the other instead of concurrently.

---

<div class="post-metadata">

**Author:** ![gregsheen23](https://avatars.discourse-cdn.com/v4/letter/g/0ea827/32.png) [@gregsheen23](https://forum.bubble.io/u/gregsheen23)\
**Post date:** [February 2, 2025, 5:48pm UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/6 "2025-02-02T17:48:47Z")

</div>

I got this working, similar to what @mitchbaylis suggested although I think there are probably more efficient methods out there. Here’s how I approached it:

1. **Create a `backend_workflow_log` entry** when the user clicks the button that starts the workflows. This is immediately in the normal button workflow so the user immediately sees the spinner.  

2. **Determine the total count** of items in each list once I receive the response from the API (which provides the lists to be processed). At this point, I update the corresponding `backend_workflow_log` entry with the total count of items for that specific list. Since I have four lists, I create four `backend_workflow_log` entries.  

3. **Track progress dynamically** by incrementing a `current_count` field in the `backend_workflow_log` entry after each iteration of the looping workflows.

4. **Control the spinner visibility** using conditional expressions:

- Show the spinner when the user clicks the button (i.e., when a `backend_workflow_log` entry is created).
- Hide the spinner when `current_count` equals `total_count` for all logs.  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/5/1/51c813169d746e259ced8b103fd2c8bf97396f48.png)

1. **Ensure all lists are accounted for** by chaining `Do a search for` expressions, so the spinner only disappears once all `backend_workflow_log` entries have reached completion (i.e., `current_count = total_count` for each list).

### **Potential Improvement Needed**

This approach works, but since I have four lists to process, I will end up with **eight `Do a search for` expressions** in a row in the spinner show/hide Conditionals. It feels inefficient, and I’d love to know if anyone has a cleaner way to achieve the same result without so many searches.

Or, maybe this is completely acceptable and efficient, which I’d also love to know

Thanks for the help

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [April 12, 2025, 1:32pm UTC](https://forum.bubble.io/t/how-to-show-a-loading-spinner-multiple-looping-backend-workflows-complete/358084/7 "2025-04-12T13:32:51Z")

</div>

Closed on April 12, 2025, 1:32pm UTC

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