Add multiple rows into a another table

There’s no loop action for n rows - you will need to create as many actions as the max number of rows you want to have.

3 Likes

Workflows can be used to loop for n number of days, when you have a table with all the possible dates (Table C). After user enters a start & end date - use a webhook workflow to run the Add action in Table B by selecting the dates in range from Table C.

  1. Create a workflow for when a new row is added to Table A
  2. Go to Manage > Integrations & Enable ‘IN:from cloud services to your app’ - Make not of the App ID - this needs to be chosen in the next step
  3. Add a new Workflow for ‘ADDS_ONLY’ for Table A. Create a ‘Webhook’ workflow action, with preset ‘Appsheet: Action’
    Body can be like this
{
  "Action": "Add",
  "Rows": [
<<Start:SELECT(Table C[Date],AND([Date] > [Start date], [Date] < [End date]))>>
    {
      "ID": "<<UNIQUEID()>>",
      "Date": "<<[Date]>>"
},
<<End>>
  ]
}
4 Likes

This solution requires a business subscription plan though.

2 Likes

No. Premium/Pro is enough.

1 Like

Ok, thanks. For those looking for documentation about this, here’s the link https://help.appsheet.com/en/articles/3454052-webhook-templates

Hello Sid, it worked perfectly ! Thank you very much + I needed a table with all the date so it is perfect !

Hello @Sid
May I ask why didn’t you used AppSheet: Add row preset instead ot AppSheet: Action preset? Is there a specific reason for that? Asking this because, AppSheet: Action preset is mostly used for triggering a Behaviour action rather than adding rows.

Besides; I notice that the Properties key is missing in your JSON template and normally when run, AppSheet server should murmur about this indicating that the Properties is missing.

@LeventK
I guess you can skip one line ("Action": "Add") in the Body, if you use the ‘AppSheet: Add Row’. I’ve not tried that though. I don’t know of a functional difference.

There are defaults for all properties, so no complaints from AppSheet servers. Left that out for brevity.

@Sid @LeventK @Kirk_Masden

Ok, I’ve been “biting my lip” on this but I’ve chewed a hole and now have to ask!

If there is a table created to select a list of dates from, why not use these provided Actions below?

  • “Execute an Action on a set of rows” - the rows are the selected dates
  • “Add a row to another table using values from this row”

I believe together they accomplish the goal with the added benefit that you can attach these actions as a group to the “Form Saved” property so that the user sees the new rows immediately on their device.

Using the Workflow, would require the user to perform a Sync to see the added rows which may not be ideal.

Am I missing something?

3 Likes

@WillowMobileSystems You are right. Using actions is better.

One additional thing the workflow offers is ability to insert data from Table A into Table B - which is not an ask here.

1 Like

If you mean updating an existing row in Table B with info from a row in Table A. I totally agree! And i should check into handling it with a webhook myself!!

By the way, there is a Feature Request to add this Action take a look and vote it up! It’s near the top in votes as it is now.

1 Like

Nice discussion.

Can someone please make a demo app so as to be able to look under the hood to see it function? Its a bit abstract to follow for those like me who have never used webhooks before.

1 Like
2 Likes

I decided to suggest a new feature instead of this convoluted approach.

See this posting:

3 Likes

Good! That is exactly what we should do in the community. Find a need for some new feature and submit a request for it.

But also, at the same time, come up with or communicate a workaround to overcome the obstacles. Because it will likely take time to implement the requested features.

If you need such functionality. I wouldn’t wait for AppSheet to implement it. It will be a while before they can roll it out.

1 Like

I am careful in what I wish for. I would not want to ask for something too complex, like reusable components (I have but it sems to be forgotten), but this is rather small and achievable in a short time frame.

A side comment is that its hard to get mass support for new features if most users are not informed of them. (A bit like politics in the real world…)

Is this demonstrated in via this wiki posting?

Hello guys,

I get stuck enriching my feature based on your solution @Sid. What I want to achieve now is this : I want to add a row every day out of 2 between a [start date] and an [end date]. I partially managed to do this with the following fomula:

{
  "Action": "Add",
  "Rows": [
<<Start:SELECT(Table C[Date],AND([Date] >= [Start date], [Date] <= [End date], MOD((DAY([Date])-DAY([Start date])),2)=0)>>
    {
      "ID": "<<UNIQUEID()>>",
      "Date": "<<[Date]>>"
},
<<End>>
  ]
}

But when [Start date] and [End date] belong to a different months (eg : from 7/25/2020 to 8/5/2020), the formula doesn’t work anymore as for instance MOD(DAY(“7/31/2020”) - DAY(“8/1/2020”), 2) = 0. The formula then adds a row for two consecutive days (the 31st of July and the 1st of August).

Any clue on how to add a row every 1 day out of 2 ? I couldn’t figure it out…

If it interests other, I also apply the formula for a selection of weekday that the user select. For instance, add a new entry for every Monday and Wednesday of every date between a [Start date] and an [End date].

Thanks a lot,
Romain

@Romagi For calculating the difference in days use this MOD(HOUR([End date] - [Start date])/24, 2 )

Thanks @Sid,

Here is how I managed to do it :

MOD(TOTALHOURS([Date] - [Date de début])/24,2)=0