Looping Workflow - Creating a thing based on the quantity of another thing

I’m hoping one of your brilliant minds can help me workout the step I’m missing in a workflow…this is what I’m trying to do:

Each ‘customer’ has a list of ‘services’. Each ‘service’ has a thing, with its quantity (like an invoice).

I want to create a new ‘thing’ for each service, which will be used in a timetable.

I have a looped workflow that works its way through the list of services, and currently it’s creating a new ‘timetable thing’ for each service…but assuming it has a quantity of 1.

I need it to take in to consideration the quantity. If a service has a quantity of 2 then I need it to create 2 ‘timetable things’ for that ‘service’

Also, each ‘timetable thing’ start time is the next ‘timetable things’ end time.

I’m never quite sure if I’m explaining things correctly, so here’s another way of what I’m try to achieve

  1. Create ‘timetable thing’ from ‘list of services’
  2. Create ‘timetable thing’ for each ‘service’
  3. Repeat creating the same ‘timetable thing’ if the quantity of ‘service’ is greater than 1
  4. Move on through rest of list, creating ‘timetable thing’ when quantity of ‘service’ is reached

PS - tried changing one thing and created 3k ‘timetable things’ for a list of 5 services :grimacing:

I don’t think I completely user stand what you’re trying to do, but is it something like this?

Customer orders a car overhaul.

Each overhaul includes the following things:
oil change - qty of 1
tire check - qty of 5
airbag checks - qty of 4

So for that one overhaul, you want to create a total of 10 “things” for the service?

If so, then you need to do an iteration of your loop.

Let’s take, for example, tire check.

You’d need to perform a loop which will create your 5 things. Your API (let’s call it add_tire_checks) will have the following additional fields:

When you first call this loop, you will send “1” as the value of the iteration and “5” as the max.

The first part of your loop will be to create the new Thing.

After that, your next step (which must also be your last step) would be to reschedule add_tire_checks, but instead of passing “1” and “5”, you’ll pass this:

So your first call will add the first tire check, and then you’ll just loop and loop to add the other 4.

Of course, you can easily end up with an endless loop that will never stop. So you want to add this check on the reschedule:

In essence, all you’re really doing is telling Bubble you want it to add 5 new Tire Check rows. In regular code, this would just be a simple do-loop, and this is just Bubble’s equivalent.

Help this possibly helps a little.

I have a video that shows you one way of doing a loop in Bubble.

For what you need, you would need to do a loop similar to this but for timetable, then do another one for services. Just create something instead of modify it. I normally do two of the loop workflows and connect them so the first one creates a timetable and then the second workflow creates each service, the starts back over to create the next timetable. Does that make sense? :blush:

Check out a simple loop workflow here: NoCodeMinute - eLearning Hub

If you need to, I can always walk you through it with a coaching session. Hope that helps! :blush:

@j805 www.NoCodeMinute.com

For All Your No-Code Education Needs:

1 Like

Thank you, yep a middleman workflow was needed! Thanks guys :raised_hands:

1 Like

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