Inserting a new row into a table

Jonathan_S
Participant V

Good Morning Guys,

How would one create an action to insert a row into a table.

I have a Table view that has quick edits enabled and have the ability to add, edit, and delete rows.

Problem is, if there is a row that needs to be inserted 5 down, currantly the user needs to delete everything up and too the 5th row, and redo the rest. Looking for a way to select a row and insert row above/below.

Any help would be appreciated

Thanks,

Solved Solved
0 12 1,651
1 ACCEPTED SOLUTION

Sample app

Data >> Columns

Details...

rows[sequence]

  • Type: Number
  • Require: ON
  • Initial value: (max(rows[sequence]) + 1)

Behavior >> Actions

Details...

increment sequence of this row (hidden)

  • For a record of this table: rows
  • Do this: Data: set the values of some columns in this row
  • Set these columns:
    • sequence: ([sequence] + 1)
  • Prominence: Do not display

move up rows at this sequence (hidden)

  • For a record of this table: rows
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: rows
  • Referenced Rows:
    orderby(
      filter(
        "rows",
        ([_thisrow].[sequence] = [sequence])
      ),
      [_rownumber],
        true
    )
    
  • Referenced Action: increment sequence of this row (hidden)
  • Prominence: Do not display

move up other rows at this sequence (hidden)

  • For a record of this table: rows
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: rows
  • Referenced Rows:
    (
      orderby(
        filter(
          "rows",
          ([_thisrow].[sequence] = [sequence])
        ),
        [_rownumber],
          true
      )
      - list([_thisrow])
    )
    
  • Referenced Action: increment sequence of this row (hidden)
  • Prominence: Do not display

move up this sequence (hidden)

  • For a record of this table: rows
  • Do this: Grouped: execute a sequence of actions
  • Actions:
    • move up rows above this sequence (hidden)
    • move up rows at this sequence (hidden)
  • Prominence: Do not display

move up rows above this sequence (hidden)

  • For a record of this table: rows
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: rows
  • Referenced Rows:
    top(
      orderby(
        filter(
          "rows",
          (([_thisrow].[sequence] + 1) = [sequence])
        ),
        [_rownumber],
          true
      ),
      1
    )
    
  • Referenced Action: move up this sequence (hidden)
  • Prominence: Do not display

insert this row (hidden)

  • For a record of this table: rows
  • Do this: Grouped: execute a sequence of actions
  • Actions:
    • move up rows above this sequence (hidden)
    • move up other rows at this sequence (hidden)
  • Only if this condition is true:
    isnotblank(
      filter(
        "rows",
        ([_thisrow].[sequence] = [sequence])
      )
      - list([_thisrow])
    )
    
  • Prominence: Do not display

insert new row before this row (inline)

  • For a record of this table: rows
  • Do this: App: go to another view within this app
  • Target:
    linktoform(
      "rows_Form",
      "sequence",
        (
          any(
            sort(
              select(
                rows[sequence],
                ([sequence] < [_thisrow].[sequence])
              ),
              true
            )
            + list([sequence] - 1)
          )
          + 1
        )
    )
    
  • Action icon: plus
  • Prominence: Display inline
  • Attach to column: sequence

UX >> Views

Details...

rows

  • For this data: rows
  • View type: table
  • Position: center
  • Sort by:
    • sequence (Ascending)
  • Column order:
    • sequence
    • name

rows_Form

  • For this data: rows
  • View type: form
  • Position: ref
  • Event Actions:
    • Form Saved: insert this row (hidden)

View solution in original post

12 REPLIES 12

LeventK
Participant V

Provided Iโ€™ve understood you correctly, Iโ€™m afraid thatโ€™s not possible @Jonathan_S

Is there a way to see what rows the user has selected? and how many?

I could just copy all rows to temp table add a new row, and re add all the rows, but would need a way to see what row the user has select.

I would only show the action insert above/below if the user has select only 1 row.

@Jonathan_S
Thereโ€™s no way to insert data in between table rows with AppSheet. The recorded data is always added after the last data row. So you canโ€™t provide that with AppSheet itself. It might be possible with Google Apps Scripting and via webhook workflow. But this will have the cons that the data will not be immediately seen in the app, the app will needed to by synced. With multiple users, this option might cause some mess provided they havenโ€™t synced their apps lately and try to do this operation which might result with unwanted data flow and mess.

Do you think it would be possible, as a row level action, that all rows after the row in question are deleted? and than add the new row, and re add those rows after?

It would never be more than 25 rows or so.

Havenโ€™t tried but I believe it might be doable with some sequential actions, dataChange workflow, or even with preset AppSheet API.

Steve
Participant V

Add a sequence column to the table, allow the user to set the value, then sort by sequence number?

@Steve,
@Jonathan_S wishes to insert data the recorded data in the gSheet back-end between rows

No to much thinking on the users end.

Jonathan_S
Participant V

Anyone else ever done this? The way Im thinking will create about 75 Sync Items

And than if the user cancels the form because they decide they dont want to than what?

Sample app

Data >> Columns

Details...

rows[sequence]

  • Type: Number
  • Require: ON
  • Initial value: (max(rows[sequence]) + 1)

Behavior >> Actions

Details...

increment sequence of this row (hidden)

  • For a record of this table: rows
  • Do this: Data: set the values of some columns in this row
  • Set these columns:
    • sequence: ([sequence] + 1)
  • Prominence: Do not display

move up rows at this sequence (hidden)

  • For a record of this table: rows
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: rows
  • Referenced Rows:
    orderby(
      filter(
        "rows",
        ([_thisrow].[sequence] = [sequence])
      ),
      [_rownumber],
        true
    )
    
  • Referenced Action: increment sequence of this row (hidden)
  • Prominence: Do not display

move up other rows at this sequence (hidden)

  • For a record of this table: rows
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: rows
  • Referenced Rows:
    (
      orderby(
        filter(
          "rows",
          ([_thisrow].[sequence] = [sequence])
        ),
        [_rownumber],
          true
      )
      - list([_thisrow])
    )
    
  • Referenced Action: increment sequence of this row (hidden)
  • Prominence: Do not display

move up this sequence (hidden)

  • For a record of this table: rows
  • Do this: Grouped: execute a sequence of actions
  • Actions:
    • move up rows above this sequence (hidden)
    • move up rows at this sequence (hidden)
  • Prominence: Do not display

move up rows above this sequence (hidden)

  • For a record of this table: rows
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: rows
  • Referenced Rows:
    top(
      orderby(
        filter(
          "rows",
          (([_thisrow].[sequence] + 1) = [sequence])
        ),
        [_rownumber],
          true
      ),
      1
    )
    
  • Referenced Action: move up this sequence (hidden)
  • Prominence: Do not display

insert this row (hidden)

  • For a record of this table: rows
  • Do this: Grouped: execute a sequence of actions
  • Actions:
    • move up rows above this sequence (hidden)
    • move up other rows at this sequence (hidden)
  • Only if this condition is true:
    isnotblank(
      filter(
        "rows",
        ([_thisrow].[sequence] = [sequence])
      )
      - list([_thisrow])
    )
    
  • Prominence: Do not display

insert new row before this row (inline)

  • For a record of this table: rows
  • Do this: App: go to another view within this app
  • Target:
    linktoform(
      "rows_Form",
      "sequence",
        (
          any(
            sort(
              select(
                rows[sequence],
                ([sequence] < [_thisrow].[sequence])
              ),
              true
            )
            + list([sequence] - 1)
          )
          + 1
        )
    )
    
  • Action icon: plus
  • Prominence: Display inline
  • Attach to column: sequence

UX >> Views

Details...

rows

  • For this data: rows
  • View type: table
  • Position: center
  • Sort by:
    • sequence (Ascending)
  • Column order:
    • sequence
    • name

rows_Form

  • For this data: rows
  • View type: form
  • Position: ref
  • Event Actions:
    • Form Saved: insert this row (hidden)

Unbelievable @Steve
Give me some time to work through all this

Unbelievable

Top Labels in this Space