Insert into loop

Hello, I have the following situation and I don’t know how to solve it in glide.
I have a table called compound services that contains a relationship with another table called simple services. The relationship is that a composite service can contain several simple services and a simple service can be related to several complex services. I solved that already.

The user can choose to schedule a composite service (in the schedule table) and I need to loop through all the simple services in the composite and insert a timestamp for each service.

Any idea how to approach this?

Would it be the same timestamp for all?
If yes, would it not be simpler if each of the simple services inherited the timestamp from the related composite service?

Hi Darren, no.
The idea is that the user insert a date and an hour for each register.
The situation is that a simple service is like a massage or a face care treatment so we need to register a date and an hour for each service.
The user can select a compose service and the app must add the simple services and the user have to insert the date, hour and the professional who will attend to that particular service/client.

Okay, understand.

Just to clarify, are you wanting update them all in one shot at the end once the user has finished making selections, or would it be okay to update them one by one?

If you want to update them all in one shot, then my advice would be to use the Glide API.

both ways work for me… picture this:

if one client wants to hire a compound service (or pack, that’s is how I call it), the user select the composite service and the app must show a collection or another component showing the simple services in order to the user could edit each of the simple services that the compound has.

If the user does not complete the entire simple services dates, does not matter because the app has to track the services that the client consume or not consume.
So the detail that I want to solve now is how to do a loop throught the simple services who already are in that particular composite service.

Okay, so I think the simplest approach would be to present the list of associated simple services as a Collection, and then change the default Item Click action from Show Details Screen to Show Edit Screen.

Then the user can edit them one by one just by clicking on them. You could add some filtering and/or sorting to the Collection so that those that haven’t been completed are shown at the top.

1 Like

Thanks Darren, I feel like the solution is on that way but, if I have

1- Composite services table (definition of services)
2- Simple services table (definition of services)
3- Agenda table (in order to register the given services)

So I would need a new table called “Agenda details” where the app would insert the choice of the client, once the services are inserted then the user could be capable of change date and hour for that particularly client.

What I mean is that I still need a way to insert multiple services from the services table into the agenda details table and that’s is what I dont know how to do.
Is there a way to repeat the “add a row” command in a loop?

So, let me sum it up:

  • You have a Composite Services table that contains a relationship to a Simple Services table. A composite service can contain multiple simple services.
  • You allow scheduling of composite services. When a composite service is scheduled, the user needs to loop through the related simple services and insert a timestamp for each one.
  • You would need to log each of those timestamps, alongside the info of Simple Services, into an Agenda Details table when a composite service is scheduled.

My suggestion:

  • Use a custom form, placed in each composite services details screen
  • Display a custom collection for the related simple services table, add a user-specific timestamp column so users can edit timestamps
  • On the backend, create a JSON structure for each row in your simple services table, and combine them in the composite services table
  • On a click of a “Finish” button, send the finalized JSON structure to, and loop through each item over there to add rows to the Agenda table

One question is if you need a row to store the composite level booking, or if the simple level bookings are enough.

1 Like

Hi thinhDinh and thanks.
A few questions:

  • In Make, how do I do the loop through the json ? I have not seen any loop option in the Make’s JSON component.
  • After the loop, I have to perform an insert from Make directly to Glide or I have to return a new JSON for every row to Glide in order to insert natively?


I believe you first want to use the JSON module to parse the JSON, then it will create a list of bundles.

If I recall right, bundles iterate themselves automatically so you might not need an iterator.

But if it doesn’t work like that, you would need an array aggregator to aggregate info from the parse JSON module, then use an iterator to loop through the resulting array.

You can use a text aggregator module to aggregate the add row actions, then use a final HTTP module to make a batch add call using the text aggregator result.

Though, do you have access to the new Call API action? That might be a better choice for you in this scenario.

1 Like