FAQ: add a set of rows

Steve
Participant V

When a row is added to a table, add a set of rows to another table.

Try the sample app!

This example uses three tables:

  1. Master Table: when a new row is added here, all rows from Source Table will be copied to Target Table and linked back to the new Master Table row. This table must allow adds.

  2. Source Table, from which all rows will be copied to Target Table.

  3. Target Table, to which all rows from Source Table will be copied. This table must allow adds.

Action 1: Copy Source Table rows to Target Table for this row

This is the action that initiates the process; invoke it upon adding a row to Master Table.

  • For a record of this table: Master Table
  • Do this: Data: execute an action on a set of rows
  • Referenced Table: Source Table
  • Referenced Rows: filter("Source Table", true)
  • Referenced Action: (set below, after action 2 is created)
  • Only if this condition is true: TRUE (or blank)

Action 2: Copy this row to Target Table

Add a new row to Target Table using this Source Table as a template.

  • For a record of this table: Source Table
  • Do this: Data: add a new row to another table using values fom this row
  • Table to add to: Target Table
  • Set these columns:
    • Parent: maxrow("Master Table", "_rownumber")
    • (other columns as desired)
  • Only if this condition is true: TRUE (or blank)

Action 1

Return to (action 1) and set Referenced Action:

  • Referenced Action: (action 2)
23 27 3,207
27 REPLIES 27

Jonathan_S
Participant V

More Wisdom

Kent_Wu
Participant II

Brilliant!

Jake_Naude
Participant V

Very cleverโ€ฆ Saved this oneโ€ฆ Thanks @Steveโ€ฆ

What does this mean here? Select the whole Source Table?

I understood equally, to return whole table.

Equivalent with

select(Source Table[ID], true),

but interesting to see what Steve would clarify.

Yep.

Correct!

Also equivalent:

Source Table[ID]

Gotcha!

por favor su ayuda, hice tal cual explica @Steve pero me surge el error y es que tengo una tabla llamada salida(es donde estรกn grabadas la fecha y hora del movimiento)

STIFFLER_0-1644905084114.png

otra tabla (MOVIMIENTOS SALIDA) que esta referenciada con IsApartOf para que me genere un formulario adicional y me permita agregar varias lรญneas al pedido.

 

STIFFLER_1-1644905168764.png

este es el formulario adicional que me genera, donde me permite aรฑadir mas lรญneas "NEW" y se ve la referencia a la tabla (MOVIMIENTOS SALIDA)

STIFFLER_2-1644905206992.png

 

y quiero que esto que se guardo me lo copie en la tabla (detalles de movimiento) pero lo ultimo que se agrego ya que al hacer el intento me copia todo lo que tengo en la tabla (MOVIMIENTOS SALIDA)

STIFFLER_3-1644905383383.png

 Esto lo hice por que debo dejar registro tanto de entrada como de salida y la tabla (DETALLES DE MOVIMIENTOS) no me permitรญa generar dos referencia IsApartOF.

 

Muchas gracias.

 

 

Hola y bienvenido a la comunidad!

Por lo que necesitas, olvรญdate de la tabla SALIDAS. Lo que tendrรกs de hacer es crear un BOT que se lanzarรก al aรฑadir una lรญnea nueva en la tabla MOVIMIENTOS SALIDA:

  • When this EVENT occurs:
    • Event Type: Data Change
    • Adds Only
    • Table: MOVIMIENTOS SALIDA

  • Run this Process: 
    • Run a data action 
    • Add new rows
    • Add rows to this table: DETALLES DE MOVIMIENTOS
    • With these values
      • IDSALIDA: [IDSALIDA]
      • ARTICULO: [ARTICULO]
      • cualquier otra columna que deseas

Swoopy
Participant V

It'd be nice-to-have if you also add descriptions in Documentation > Descriptive comment for each component of the sample app.

JPAlpano
Participant V

Hi @Steve 

What should be the referenced rows expression if I want to get unique records based on a column only?

JPAlpano_0-1660526410953.png

FILTER("Source Table", true) will still give me JOHN DOE twice since Filter gets unique based on ID.

I tried using SELECT(Source Table[EMP NAME], true) but the action button wouldn't work since the expression does not reference the ID.

Thanks in advance.



 

The first row of each distinct employee name:

 

FILTER(
  "Source Table",
  (
    [_ROWNUMBER]
    = MIN(
      SELECT(
        Source Table[_ROWNUMBER],
        ([_THISROW-1].[EMP NAME] = [EMP NAME])
      )
    )
  )
)

 

 

suzukixxx
Participant II

thank you for always.
My problem may be solved with this function. I am using it as a reference.
I have a question because I want to add functionality.
I want to create an action like below.

First add a category column to the source table to categorize the tasks.

Source TableSource Table

Next, specify the category when creating rows in the master table.

โ€ƒMaster TableMaster Table

Then, tasks will be added only for the category specified when executing the action.

Target TableTarget Table

To achieve this,
Isn't it enough to change the filter
("Source Table", true)?

Yes, use the following as the Referenced Rows expression:

FILTER("Source Table", ([Category] = [_THISROW].[Category]))

thank you! I was able to use the same functionality in another app. It's inspiring.

In this app, "Parent" of "Set these columns" is specified with "MAXROW". Is it possible to specify this as the Row Key of the entered form? With MAXROW, there is a possibility of picking up the latest Row Key when correcting the previous master table.

Steve
Participant V

@suzukixxx wrote:

Is it possible to specify this as the Row Key of the entered form?


No: the action is performed from a row of a different table and does not have access to the data of the form.

Thank you! I'll try to find another approach. I think it would be very convenient if you could register the composition table of parts and recipes with a single button. I am always grateful for your help.

sathishk
Participant III

Edit: Figured it out, using bots i can add only for Action 1. Thanks

@Steve  Thanks a lot for this masterpiece! 

May i ask how can i avoid ACTION 1 when i edit the existing record for Master Table?

Steve
Participant V

@sathishk wrote:

May i ask how can i avoid ACTION 1 when i edit the existing record for Master Table?


Perhaps configure your bot to only fire on adds?

Yes, thanks Steve!  i revised them now

Hi @Steve , will it sync as one task (regardless of the number of rows) or per row syncing?

The process I've described does not itself perform or affect the behavior of sync. Sync behavior is controlled by the Delayed sync option.

If you have Delayed sync enabled, the added rows will sync while the user continues to use the app If Delayed sync is disabled, I believe a sync will occur automatically immediately after all rows have been added and the user will have to wait for the sync to finish.

Are you sure that referencing to Parent by maxrow("Master Table", "_rownumber") is safe? For example if Action 1 is fired many times at once by selecting some rows in table by the user and clicking "GO" than all calls of Action 1 will generate calls ofAction 2 and then calls maxrow("Master Table", "_rownumber") and in the end inserting to Target Table can be done with incorect Parent row id values.

You will need some kind of "semaphore" tool to do it properly.

I am writting this because I have exacly this problem. I need to pass PARENT_ID parameter to Action 2 and I do not know how to do it.


@AndrzejS wrote:

I need to pass PARENT_ID parameter to Action 2


Consider INPUT. Although it's only a beta feature, my observation is that it works reliably in this scenario. Here's one fleshed out example: Expand/Collapse Button Groups - Google Cloud Community.

INPUT Works only with update action not with insert action.

I use this approach in "update" situation in my app but this time I need to insert.

Gracias Steve sos un gran aporte para esta comunidad 

Top Labels in this Space