FAQ: Add a number of rows

Add an arbitrary number of rows to a table based on a column value of type Number.

Try the sample app!

For this example, the table from which the row-addition process will be initiated is called Control Table. The table to which new rows will be added is called Target Table. Use your own names as you see fit. Note that they could even be the same table. Control Table must allow updates; Target Table must allow adds.

Control Table must have at least two columns for this process: Finish Count (type Number; the number of rows needed; may be virtual); and Add Count (type Number; the number of the next row to add; may not be virtual). Column names may be changed as desired.

Finish Count should have Required? set to ON. Add Count should be blank or zero.

Action 1: Add Rows for Remaining Count

This is the action that you should invoke to add the rows: it does everything.

  • For a record of this table: Control Table
  • Do this: Grouped: execute a sequence of actions
  • Actions: (added below, after creating actions 2, 3, and 4)
  • Only if this condition is true: OR(ISBLANK([Add Count]), ([Add Count] < [Finish Count]))

Action 2: Increment Count

This manages the Add Count column value, which contains the number of the next row to add. It’ll start at 1 and increment to Finish Count.

  • For a record of this table: Control Table
  • Do this: Data: set the values of some columns in this row
  • Set these columns:
    • Add Count: ([Add Count] + 1)
  • Only if this condition is true: TRUE (or blank)

Action 3: Add Row For This Count

This action adds one row to the Target Table table for the current value of the Control Table row’s Add Count column.

  • For a record of this table: Control Table
  • Do this: Data: add a new row to another table using values from this row
  • Table to add to: Target Table
  • Set these columns:
    • (columns as desired)
  • Only if this condition is true: TRUE (or blank)

Action 4

This action implements a loop by recursively performing action (1) for each successive number in the indicated range, from 1 to Finish Count.

  • For a record of this table: Control Table
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: Control Table
  • Referenced Rows: LIST([_THISROW])
  • Referenced Action: (action 1)
  • Only if this condition is true: TRUE (or blank)

Action 1

Return to action (1) and add actions (2), (3), and (4) to its Actions list.

  • Actions:
    • (action 2)
    • (action 3)
    • (action 4)
12 Likes

Very interesting, I’ll try I was looking for something like this, it would be great if there is a way to update if number already exist.

Thanks for this tip. I was looking for something like this, to add rows, for a monthly budget (I have to create/add the next 12 months, one month per row…). This does the job.

As a newby, some problems are not intuitive. Could be nice if appsheet add an action to mimic ‘for each/do while/repeat until/’ to do this more easily.

1 Like

This seems like a much simpler approach than this:

Is it the same result or am I missing something?

IN my case [Finish Count] is a VC that counts the elements on a list type column,
What if I want each of the new rows to have one of the different elements of that list? Is that possible?

i.e.
[Example] (List type column): A, B, C, D, E
[Finish count]=5
New rows: image

1 Like

@Nicolas_Feldman
Try this:

1 Like

Is there any sample app using this set of actions? I would like to see an app using them in order to understand better how it works.

Thanks in advance

Like the one linked as the second line of the post?

2 Likes

I have been using this for a while and its working perfect. As i have bulk rows to add each time instead of attaching this with an ACTION i have done it using WORKFLOW.

Does this effect looping action once its completely migrated to BOTS ?

I have scenarios where three looping actions are executed at the same time into 3 different tables on adding a row in parent table. I have created 3 different workflows for that. Will this migration to BOTS effect what we have right now ?

Sadly, the answer should be “who knows”…

I just hopeing the existing Workflow could be transformed automatically onto BOT without any problems with us.

3 Likes

If it’s like that. I might have to stop all my applications and find a new way to achieve the same.

As far as you are able to achieve your goal with Action only, like looping actions, there should be no necessity to involve Automation.

I am not able to achieve it using actions because i have 3 tables to updated in parallel. If i attach the action on save it actually worked for one table or one set of looping action. I have multiple sets of looping actions.

I m not sure what your exact requiremet will be, but should be achieve with action only. But set ups is surely complex though.

1 Like

It’s very simple. Here is an example.

I think this is a good news Editor improvements to Automation