Looping with actions

Steve
Platinum 5
Platinum 5

Kinda burnt out and just wanna get this out. I’ll try to circle back later and provide some documentation.

https://www.appsheet.com/samples/Examples-of-loops-using-actions?appGuidString=7b9ae746-1f51-4ecb-8c...

31 40 8,547
40 REPLIES 40

@Steve

I would say this is a chunk of new features I would call! Thank you Steve. It probably takes a bit of time for me to digest and to understand the tricks behind, but it will be exicing journey for sure to get new skills and tools to enhance the functionalities of our apps!

Is this an extended usage of your tricks of this ?

Appreciate for your documentations anyway!

Thank you again Steve for all of your hard works to come up with this.

Yes, or maybe more of an evolution. My prior demo required a minimum of three actions, where this demo requires only two. Everything else is just applications of looping for common use cases. I intend to add more over time.

Sounds more great Steve.
Lesser number of actions involved could improve the performance of the app, saving the change in data on the backend data base faster than previous tips I hope. I implemented the previous tips to my app, and added number of rows like 50 rows, it takes a bit of while to complete the operation.
Does not have exact stats how long each tips will take time, but quick test gave me a feeling those new tips with 2 x actions perform faster.

Looking foward to seeing documentation and additional tips with interest.

I categorized your tips to “Appsheet hall of fame”

Started to dive in deeply to learn the essense of the tricks, even though i m still on the very first stage. For the action of “Add by Count”, now I understood how the combination of actions will do the jobs nicely, I will be moving onto the other actions which is getting more difficult to understand though!

For Add by Count, I thought removing “only if” constrain expression from " add by count: loop" action may end up the infinite loop. I tested (at my risk!) and saved the app editor. Run the action to add small number of copy (3), then tried to save the form. but I could not. Actually app editor “freezed”, i refreshed the browser. Tried few times and indeed app editor continuously freezed.
Pushed expression back in and save. Then back to normal, and operational.
FYG, Steve.

Yep!

Thanks! @Steve
Will check it out.

This is really excellent help. I’ve looked through them in the sample app, and can’t wait to read the documentation to help me understand them better. Thank you very much, Steve!

Thank you @Steve for this another very useful tip on looping actions.

Hi @Steve, your sample App is no more accessible. Could you share the link so we could copy the App?

I think embedding is broken. I’m updated the original post with the link to the app:
https://www.appsheet.com/samples/Examples-of-loops-using-actions?appGuidString=7b9ae746-1f51-4ecb-8c...

Hi @Steve,

This post is awesome, thanks for sharing. I have used it for a couple of apps. Would it be posible to do a loop inside a loop? I would like to distribute 100 task to 10 different people. How I have set up right now is that I would have to do this 10 times, one for each person to assign them 10 tasks each…

Definitely possible! It’s just a matter of structuring the control table(s) properly and adding appropriate actions.

Thank you @Steve for this.
I was able to make this work for adds/updates that happen within the app.

Im looking for a way to trigger this automatically when adds/updates happen directly on the spreadsheet not on the app. Im using Zapier to fill the spreadsheet with information from our reservation manager.

So I would like this to be triggered anytime there´s a new row added to the Spreadsheet.

I thought about using a Report to trigger this once a day for all the “new bookings of the day”, but Im not sure if this will work since this “looping action” is basically for individual rows.
Is there a way to select a group of rows to copy instead of just “the” row that is added or updated?

If you’re using Google sheets, one way could be to use Google apps script and AppSheet API to trigger the actions.

Thank you so much @Bellave_Jayaram

I am not very familiar with coding, and never used GAS before, but will give it a try. I already read some posts about it what you mentioned before:

but only found how to trigger GAS from events happening on Appsheet, not the other way around.
Do you have any documentation or links handy that could point me in the right direction?

Thanks so much!

There are several posts relating to this, for example- I am using the onedit function which in googl... - #13 by Nick_Parsons

@Steve some sort of documentation or explanation of how all this works together would be much appreciated.

I’ve been digging through the app for about 25 minutes now, and I’ve only got a vague idea of what you’re doing.

hello friend.

One of the resoures for looping stuffs which I provided is here.

Add rows based on the selection of Enumlist on parent record, then add child records on save. Just using tricks from @Steve.EPL

Just as one of the resources for the community. You can find my sample donw there and dig into it.

Hi, here is another example. Same approach, but a bit simpler because it’s not using Control Tables / Columns

Can I add Quantity with Product name in The Loop.

Did you know:


If you put additional actions AFTER the repeater action, they only fire once the loop is complete?

For instance: in this loop, I first create child records based on an enumlist inside the parent;

  • once all the child records are created (and the loop is complete):
    • I then create grand-children records (each associated with the newly created child).

Matt, this is awesome to learn. When you get a chance, it would be great if you created a sample app (or take one that someone created and modify it) where people can look inside to learn.

Dear Matt, what a great man you are … What a kingdom is this !!! I also thank you.

Excelent work, for me this means that appsheet can cover any task 100%, this solution should be extra highlighted

Hi,
this seems great to me.

I’m wondering if i can use something similar for my project, or is better to try another way.

It is a little bit different scenario.
I’d like to use it to generate a checklist.
I have 3 table.
Todolist (clean checklist, each row is one step)
Job (blank table, add row to start new job)
JobEvent (list of step to complete the job)

So i have a table with my checklist, every steps, one row…not the usual in row checklist plenty of Y/N.
I’d like to copy every steps in a new table “event” where the user can edit, do action, add note…on every rows (step), so i can restart the checklist maintaing the todolist clean.

thanks

Yes you can apply the looping to create the checklists when the parent Job is created. I have done very much the same thing.

thanks,
do you have some example of that?
i’m struggling with the structure at the moment.

I do not.

Thanks Steve, excelent work, i am still trying to fully understand the control table and how to pass the list to rows but there’s light on the end of the tunnel. Thank you

Hi @Steve, your tip was all I needed ! Thanks for your devotion to help us. I had done using Google Apps Script, but It’s much better to use recurrent Actions. In my case, I used an Enumlist field to save all child records keys I needed to create and subtracted it after each loop. So, the condition to loop is if this field is not empty.

Dear Steve,

I have Two Modules, Sales Quotation and Sales Order.
The Sales Quotation have Related Child, which is Sales Quotation Details, consists of Items, and Related Payment Terms, consists of payment terms.
I'm creating an action button "Convert Sales Quotation to Sales Order" where I want to Duplicate the [Sales Quotation] table (Parent) to [Sales Order] table (Parent). The Sales Order table will have similar columns with Sales Quotation, with the additional of SQ No. and Contract No.
I am able to achieve this since direct copy is easier to do.
Now i got problems when creating the child records for Sales Order Details, since I want to Copy the selected / desired Sales Quotation Details (Child), to Sales Order Details (Child), where I also need to put "Sales Order No." from it's new Parent [Sales Order] table.

Can you give some advice?

thank's a lot.

 

Instructions for Creating a Cloning Action with Associated Records

  1. Create a Main Action in the Parent Table

    • Define an action in the parent table and name it, for example, "Clone Record." Its purpose will be to clone a record along with all its associated child records.
    • This action should be of the type "Grouped: Execute a sequence of actions."  (ACTION1 & ACTION2).
  2. Configure the Grouped Actions

    • Action 1: Copy the record from the parent table.
      This action should add a new row to the destination parent table using the values from the current parent table record.
    • Action 2: Clone the child records.
      Design this action to copy the associated child records from the child table to the destination child table.
  3. Create a Specific Action for the Child Table

    • In the child table, create an action named "Clone Row" to add values from the original child table to a new destination child table.
  4. Set Up Execution from the Parent Table to the Child Table

    • In the parent table, configure the grouped action to include an action that triggers the cloning of child records. This action should operate on the list of related child records, typically stored in a list column such as [Related_Childs].
  5. Complete Workflow

    • When the action is executed from the parent table:
      1. The current record in the parent table will be cloned into a new row.
      2. The associated child records will be copied and linked to the new parent record.
  6. Field Configuration

    • In each action, adjust the field values to ensure that the data is consistent and correct in the destination tables. For example, update key references to properly link the child records to the new parent record.

I hope this can help you.

Thank you for your kind reply and advice. I'm still confused, but trying to understand your steps.

Thanks a lot.

Dear Gustavo, I'm a bit confused about Cloning the Child. 
Since the Child Source will be "Sales Quotation Details" with keys SQ_No and SQ_RowNo and the new destination Table will be "Sales Order Details" with keys SO_No and SO_RowNo.

Now, the new copied record in the parent table (Sales Order) will have a unique SO_No (Sales Order Number) which is auto generated using certain formula that I made. So how can i grab this new SO_No (Sales Order Number) to the newly cloned child table (Sales Order Detail)?

Looking forward for your advice.Thank you.

 

I would recommend starting a new post with a specific question. Not only because this is the Tips & Tricks section and we're cluttering Steve's post with things unrelated to his original content, but also because doing so will allow you to receive not just my help, but the assistance of many others as well. You'll also have the opportunity to explore solutions and mark the correct one when the time comes, which can help others facing similar challenges in the future.

Please remember to include the full problem description and a step-by-step explanation. Often, when we formulate the right question, the solution becomes clear to us even before we expect it. If that's not the case, I will gladly address your question when you post it, as I am currently not fully understanding your needs due to my lack of familiarity with the structure of your database and what you're aiming to achieve.

Dear Steve, thank you for your kind samples.

I'm making two modules: "Sales Quotation" and "Sales Order".

The Sales Quotation module, consists of three tables: [Sales Quotation], [Sales Quotation Details], and [Sales Quotation Payment Terms]

While the Sales Order module, reflecting similar tables, consists of three tables: [Sales Order], [Sales Order Details], and [Sales Order Payment Terms].

 

I want to create a button (Convert SQ to SO) in the Sales Quotation, which will do several actions:

  1. Create a new record in the [Sales Order] table using data from [Sales Quotation] table. The New Record will have a unique Sales Order No (SO No) generated using our own code in Initial Values.
  2. Create child records in the [Sales Order Details] table using data from [Sales Quotation Details] table.
  3. Create child records in the [Sales Order Payment Terms] table using data from [Sales Quotation Payment Terms] table.

 

I managed to do action no. 1, since it’s a direct copy between parent tables [Sales Quotation] to [Sales Order]. But I have problems that are confusing me to do a loop for copying data from [Sales Quotation Details] to [Sales Order Details], since doing so will need me to put the newly generated [Sales Order No.] from the [Sales Order] parent table.

The problems also occurred with the Payment Terms.

 

I need your advice.

 

Thank you.

Top Labels in this Space