We just added an initial version of a new action ‘Data: add a new row to another table using values from this row’
Please try it and give us feedback. Documentation, etc coming later this week. The brief version is here: let’s consider an example with Orders and OrderDetails as two related tables in an app.
Add an action ‘CreateChildRow’ to the Orders table that will add a row to the OrderDetails table. You can specify expressions to assign to each column of this row. For example: Order = [Order Id], Product = “Bananas”, Quantity = 5. Note that [Order Id] here is the value of the column OrderId in the Order row on which the action is being performed.
Use this action in the UI, or compose it with another action, or use it in a workflow rule when a new Order is created, etc.
Any columns not defined will get their initial values or app formulas. If a required column is not specified and does not have an initial value, you will be shown an error in the editor.
Thanks for this! Really looking forward to the docs + some examples of dynamically adding multiple rows to another table. That would really enable me to stop spending cash on Zapier/Integromat integrations…
@praveen. Had a look at it last night. Couple of questions. Maybe I am missing how.
How do you add multiple rows, meaning for multiple rows that fits a criteria or rule
I see Columns marked as REF in the Parent table is not available in the list if Columns one can select. I have a case where I want the value in that REF column to also be “defaulted” to the Child Table Record
It is a variant of the OrderCapture sample. It has three actions and a workflow rule:
‘Prefill 2 Apples’: the action is on the Orders table and it adds a LineItem row for that Order, asking for 2 apples
‘Prefill 3 Bananas’: the action is on the Orders table and it adds a LineItem row for that Order, asking for 3 bananas
‘Prefill’: the action is on the Orders table and it composes the previous two actions. It can be invoked directly via a UI button (try it in the app) or via a workflow rule.
A workflow rule that runs when a new Order is added — this automatically calls the Prefill action (which adds two LineItems to the order)
Now, I’ve marked this as a public sample, so that any of you can see it. However, this means you will not be able to save/sync any updates. So if you’d like to play with it, especially the workflow rules, please make a copy.
Just checking. It it possible to only create new one row per action?
I’m going to be building an App where it will need to do the following:
A row in TableA is changed
Based on a matching condition - TableA[ColumnA]=“Banana”
It copies all rows from TableB to TableC where TableB[ColumnA]=“Banana”
TableC is a subtable of TableA
Will this be possible or is it a Google Script job?
Imagine we have a MASTER table which has an EnumList field called LINE-ITEMS which contains 5 choices - ‘Andrew’,‘John’,‘Tim’,‘Dave’,‘Mike’.
Naturally, I have got a DETAIL table where i expect the new line-item rows to be created based on my choices in the EnumList.
I then go ahead and create a new MASTER entry and select choices ‘John’, ‘Tim’, ‘Mike’.
The app then should create the following entries in the DETAILS table
+------------+-----------+
| DETAIL_UID | LINE-ITEM |
+------------+-----------+
| 1 | John |
+------------+-----------+
| 2 | Tim |
+------------+-----------+
| 3 | Mike |
+------------+-----------+
If I was to use your method, I would have to have a Grouped Action specifically for the scenario of the EnumList containing John, Tim, Mike… which means that I will be forced to create a ton of Group Actions for each possible combination.
I still think it’s a nice addition to have though, i don’t think it’s for me at this point (unless i missed something)
How would this work when you want to copy a different number of rows each time?
e.g. A Customer wants to repeat an Order, with all related Line Items. Each time they want to copy a different order, with a different number of line items- copied to the new parent Order.
Would we have to just guess at the max number of related rows (Line Items) per Order, and have that many individual actions grouped to copy them? How do we loop through the list of REF_ROWs when the number of values is not fixed?
Define an action on TableB that copies a row over to Table C
Define a “reference” action on TableA … it identifies a set of rows in TableB and for each of them, invokes an action (the one you defined in step 1) on that row
Now trigger the reference action via a workflow rule with the matching condition.
have a separate Details_Template table with five dummy rows in it, one for each of the choices.
Define an action on this Details_Template table to copy a row into the Detail table
Now define an ‘reference’ action on the Master table … this defines an expression that identifies a set of rows in the Details_Template table (those whose name matches something in the enum list column of the Master row) and invokes the copy action (defined in Step 2) on them
Combine this new kind of action with a reference action.
In a reference action, you provide an xpression to compute a set of row references. And an action to take on each of those rows. If you invoke an action that creates a new row in another table (effectively a “copy”), then it achieves what you want, I think.
I tested this and working perfect. Thank you for implementing this awaited feature!
On the backend, API POST call should be running. POST methods could be relatively simple rather than Update row(s), but does your team have a plan and roadmap to introduce similar for the other verbs , especially, update!