Add multiple rows from one table to another using a form & action instead of one by one with a form

Friends, I’m going to share an intermediate tip (if we want to rate it by difficulty level; neither too hard nor too easy) since it requires some knowledge about actions.

The idea is to add multiple rows instead of just one when saving a form.

Let’s suppose there is a "Table 1" that contains records used as a reference in another "Table 3," where, when we enter, we can add records by selecting values from a dropdown list as usual.

Now, let’s suppose we have a "Table 2," and we are in it. We need to add a number "n" of rows to "Table 3," which has a Ref field to Table 2, with preloaded values, instead of adding them one by one from "Table 3."

Step 1: Add two columns in "Table 2"

  1. A Yes/No column called "editing" with "reset on edit" enabled and an initial value set to an IF condition:

    • If it's in the context of the new form (to be explained later), set it to true; otherwise, set it to false.
  2. An EnumList column with a Base Type of Ref pointing to "Table 1" with "reset on edit" enabled. Let’s call it "Table 1 EnumList."

    • In the Valid If field, enter Table 1[id] (or a filtered list if needed).
    • Mark it as required in the context of this form.

Step 2: Create a New Slice for "Table 2" with Two Fields:

  • Row ID from Table 2
  • Table 1 EnumList

Step 3: Create a New Form based on the new slice "Table2_slice" with Two Fields:

  • Row ID from Table 2
  • Table 1 EnumList

Step 4: Create an Inline Action in Table 2

  • Assign it to any column (a virtual column exclusively for actions is recommended, with the formula "").

  • The action should be "go to another view within this app" with the formula:

    LINKTOROW(
        [_THISROW],
        "Newly Created Form"
    )
    

This action redirects the user to a form where they see this row and the EnumList with labels from Table 1 (which can even appear as initial values).

Step 5: User Selection in the Form

  • The user can decide whether all items in the EnumList should be copied or only some (by deselecting unwanted items).

Step 6: Create a Grouped Action with 3 Actions:

Action 1:

Execute an action on a set of rows

  • From Table 2 to Table 3 (executes Action 4).

Action 2:

Set values of some columns in this row

  • Set [editing] = false

Action 3:

Go to another view within this app

  • Use the expression:

    LINKTOFILTEREDVIEW("Table 3", [Table 2 Ref Value] = [_THISROW])
    

Group these actions in a new action named ACTION 5.

Step 7: Create Action 4 (for Action 1)

Add a new row to another table using values from this row

  • Assign [Table 2 Ref value] as:

    ANY(FILTER("Table 2", [editing] = true))
    
  • Copy the rest of the fields as needed.

Finally, go back to Action 1 and configure it to execute Action 4.

Step 8: Triggering the Actions on Form Save

  • Go to the form view settings and set the "Form Saved" event to trigger Grouped ACTION 5.

With this setup, when saving the form, the grouped actions will execute, adding multiple rows to another table in the desired quantity.

Hope this tip helps! It may not be super advanced, but it will definitely save you time. 

0 0 131
0 REPLIES 0
Top Labels in this Space