New Action: Add a Row to a table

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.

  1. 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.

  2. 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.

21 Likes

Nice, works great. Thanks

1 Like

So pumped for this feature! Thanks for the release.

1 Like

What!!! Absolutely Outstanding!! A million thank you’s for this one! :):grin:

1 Like

This is huge!

1 Like

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…

3 Likes

@praveen. Had a look at it last night. Couple of questions. Maybe I am missing how.

  1. How do you add multiple rows, meaning for multiple rows that fits a criteria or rule
  2. 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
2 Likes

Here’s a sample: https://www.appsheet.com/Template/AppDef?appName=Customers3-16350

It is a variant of the OrderCapture sample. It has three actions and a workflow rule:

  1. ‘Prefill 2 Apples’: the action is on the Orders table and it adds a LineItem row for that Order, asking for 2 apples
  2. ‘Prefill 3 Bananas’: the action is on the Orders table and it adds a LineItem row for that Order, asking for 3 bananas
  3. ‘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.
  4. 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.

6 Likes

This is awesome! i’ve been waiting for this for a long time!! Thank you so much! :smile:

1 Like

Hi Praveen

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?

Simon@1minManager.com

1 Like

@praveen

Hmm but that is pre-set to add 2 rows.

Here’s a typical scenario I get faced with.

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) :+1:

2 Likes

@praveen, this is EXCELLENT! Thank you!

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?

2 Likes

Great to hear, been waiting awhile for this feature!

1 Like

Hi Simon, here’s how to model this:

  1. Define an action on TableB that copies a row over to Table C
  2. 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
  3. Now trigger the reference action via a workflow rule with the matching condition.
1 Like

Hi Alex, here’s how you would achieve that.

  1. have a separate Details_Template table with five dummy rows in it, one for each of the choices.
  2. Define an action on this Details_Template table to copy a row into the Detail table
  3. 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
2 Likes

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.

3 Likes

Great, then i dont need to struggle with API and testing on Postman !!! This will save massive time.

1 Like

Love you guys! I’m a med student who doesn’t have much time to tinker with webhooks and this is going to make my med app dreams come true!

3 Likes

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!

2 Likes

… Including HTTP GET

1 Like