Iterate through an array to create new rows

Hi Glide family

I’ve got an array which could have x number of names based on the user’s choices in a form. This could be anything from 0 names to any number of names, depending on how many they choose (the maximum number of names is unknown, as the user gets these names from a ‘contacts list’ they add to separately in the app, which in theory could be infinitely long).

The user selects these names, and then fills in the rest of the form to add other attributes.

I want to take every name in the array and create a new row, one name per row, with the other columns for those names populated with the values from the rest of the form (which would be the same value for every row).

Is this possible in Glide? I came across another similar topic which talked about single-value columns and going through each element in the array one at a time, however if I don’t know the maximum number of contacts in the array, I’m not sure how I’d do this.

Hola @rathbala

Unfortunately, we can’t create a dynamic table in Glide (Glide Table), this has to have a static or finite number of rows to hold your data.

But let me understand better your case, do you want to show a large list of names using a choice component? Why don’t you use a relation tied to a choice?

The choice component supports multiple relations so, it will show a dynamic list of names ready to be used by users.

Saludos!

I think what you can do is using an external service like Make:

  • Send the list of names (or better, you can show it as names on the front end but write rowIDs, just for the sake of preventing duplicated names).

  • Use an iterator to iterate through the array of names/IDs that has been split.

  • Batch the HTTP calls to write rows to the destination table.

2 Likes

Thanks both! I’ll need to explore Make some more @ThinhDinh, it seems like a powerful tool that I’m not making use of properly at the moment. I’ll explore this approach.

Much appreciated!

1 Like

Feel free to let us know if you have any questions!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.