Generate several entries in one table based on single entry in another

Hello all,

To provide context, my app has a table for INGREDIENTS, I can enter entries there in order to be able to generate RECIPES

In the RECIPE I can create multiple lines indicating INGREDIENTS that will be assigned for the recipe, quantities and some other relevant data

For instance I can have the RECIPE called “fried eggs”

To have 1 unit of “fried eggs” I need

1 unit of Eggs

20 gr Oil

3 gr Salt

I would like to create a view called ORDER where user can add lines indicating RECIPE ID and a quantity, for instance

3 units of “fried eggs”

After this and pressing one button I want to create 3 lines in another table, those lines will include the INGREDIENTS for the RECIPES and quantities indicated in ORDER

I have elaborated 2 approach for this

Solution 1: Creating a script file and write logic to do the calculations I need

Create a button that will populate a dummy entry in one table, entering a record in this table will trigger a bot that will call the script and do everything

For me this solution looks the best, there is a minor inconvenient that virtual columns you cannot access from the script and have to replicate calculations

Solution 2: Create a table in Spreadsheet, create a table with lot of dummy entries with unique ID

With filter(), query() or similar expressions I can generate the table with the data I want, provide user capability to select all records and press some kind of post button

My first natural question is that if there are different solutions to solve this and I am also curious about what approach is the most efficient

Thanks a lot for support, this community has been really helpful many times

Create an action that adds the needed rows. Attach the action to the form view as its Form saved event action.

2 Likes

As you can have a lot of rows to add, I think the easiest way is to create those rows with the Automation either with actions or webhook using AppSheet API.

2 Likes

From ORDERS I can get RECIPES into auxiliar table and execute an action using form event to insert those rows into final table

Thanks a lot for the hint !!!

1 Like