Adding multiple rows dynamically based on sizes - Need Logic

Hello Guys,

I am trying to find a flow and logic to this but its going out of my head.

There is a scenario where a client submits the form with product sizes, then each such sizes should be added as separate row in another table after form submit.

This is how fields for table is visible in the form.

In first row (first size), first two fields are mandatory to be filled up. Other sizes are optional. And there is a bulk size in bottom, if selected, only Unit is mandatory.

On form submit, I want to add these sizes as separate rows to another table (Add Row action). However, since some of these fields are optional, even on first size, I am not sure how do I add those details to add row actions.

Initially I did was, combine all sizes as single column, all units in single column etc, then split those sizes and units etc. and using single value I would add row, but then I realised what if Client has not filled up some of the non-mandatory fields. That will break logic.

Can someone guide how to achieve this?

Can you explain your tables to me? Where is this form reading from/writing to?

There is master product table. Client will submit a form for new product with all relevant details. In this form, I am having these fields (screenshot attached above) which will write to Master Product table. However, upon submission, I want to configure an action where if Client has added sizes (Atleast one should be mentioned while submitting form), then each such size should go to another table named “Sizes” which will be linked Master Product table.

Please note that each size will have Qty, Unit, Item# and Weight in Lbs. Qty and Units are required field to add a size. Item# and Weight are optional fields.

Additionally there is separate fields for Bulk size as well which should also go to Size table (similar to other sizes).

Problem: I am looking at a scenario where

  1. client has added two sizes but without Item# or Weight OR
  2. Client has added One size with all fields filled up but may partially fill up second size

So I am just trying find a way to make none of the scenario breaks the logic of the App.
I hope I am explaining it correctly.

One thing I’ve done before was force something in the empty field, for example, a dash “-.” It ends up being comma-separated. Hacky, but it works :sweat_smile:

Looking at this picture + reading about optional sizes, my immediate thought was to use progressive disclosure. So you would start with just one size as you have it here, and then add a button that says “add another size.” Glide probably won’t be able to create fields like this on the same page, but there’s no reason why an overlay form won’t work…

Also, as I’m writing this, why not use a collection/table here instead of the form?

You could cover the empty states with a couple of ITE columns and submit the final ITE column instead.

E.g. if weight2 → is empty → ‘NA’ → else weight2.

…and since some of your sizes are optional a second ITE column… if Size2 → is empty → blank → else (if empty weight2 column)

The end result should be if a size is not empty then the weight will either be ‘NA’ or the users inputted weight… and if a size is empty then the weight will be blank.

1 Like

That is good idea I will try that.

I already did this but, since its a screen form, it was not allowing me to use button more than once.

The form I am using is to submit the details of Product for the first time. So if I use overlay form for sizes (before the actual form is submitted), I won’t have product details in Size table and won’t be able to link product with sizes.

How would I link a product (which is not yet submitted to Database) to the sizes which I will add through Table/collection?

Thank you for all your help

Ok, I see what’s happening. I thought that the Form screen would behave the same way as add row (create an empty row as soon as the screen is open), but it doesn’t.

Can you break up your flow into two steps?

  1. Create a product
  2. Open the Detail screen where they can add sizes?

So, something like this?
CleanShot 2023-05-22 at 11.24.00

I have initially done this but client wanted to give an option to add Sizes at the time of this form submission. In any case, they are getting an option to add sizes in detail screen if they want to add any time afterwards.

Thank you

Well, how about this
CleanShot 2023-05-22 at 13.40.46

The “Add” button opens the detail screen for this sheet

Sizes are added via a form container that has visibility condition for product_name not being empty and passes product_name as an additional column to this table on submit

When you click “Save” at the top, a custom action:

  1. Adds a new row to “Products”
  2. Clears values in This row
  3. Goes back to the list of products

UX is a bit funky if you use an overlay, but I think you can play with it a bit?
CleanShot 2023-05-22 at 13.49.48


I see you are struggling with this subject… and I will advise you to change your data structure… is never a good practice to add multiple rows for one record… also having separate tables for the same items… will always create problems for the data analytics and editing.
Add more columns… not more rows or tables. Most of the data structures need only two tables, Users and Data… then you just use filters to fish out what you need.

1 Like

Thank you @Tamara_Didenko for all your help. This option looks better. I will try to implement this and see if that is viable option for App.
However, the only issue I feel is, since its on detailed screen, it may cost lot many updates because I have many fields to be filled up on the initial form.

But I like your innovative way of thinking. I will sure try this option. Thank you so much.

1 Like

Hi @Tamara_Didenko I finally end up using this idea using a dash. I had to create many additional columns of IF THEN ELSE but atleast it worked. Thank you for the idea.

1 Like

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