Looping over several rows

I am wondering if we can loop over tasks using START and END for lists and Enumlists.

I need to add rows to another table using rows from this table and this table has Enumlist columns over which I need to loop.

This may be a different question but how about nested loops involving children and grandchildren?

It’s painful but doable to handle LISTS and ENUMLISTS.
Have to keep adding Branch if Condition steps for as many as required until max length of LIST.

Please consider a way to specify a step which is essentially a loop over the LIST or ENUMLIST.

Mr Jay, you can do that with Webhook as you are able to use Start expression.

I don’t want a webhook!!

So I’ve got a system inside an app I’m working that does exactly what you’re asking for @Bellave_Jayaram - but with actions.

  • From a Parent level, we create child records, then associated grandchild records (with the grandchildren being related to both the parent AND the appropriate newly-created child).

I spent some time this morning trying to figure out how I could port this process over to the automation side… and I think I got it figure out - but I only got as far as looping through the list and creating the child records and ran into a bug due to a cycle.

If we could get processes to accept cycles - as long as the first step in that process is a condition - we could “easily” implement a system that would allow us to loop over lists.

  • And since processes allow us to essentially “push” data into other tables, it would solve something that’s been desperately missing from the platform FOREVER.
    @prithpal

This… might be a long video - just fyi. (^_^)

Hey!
I join this task.
Before automation I had to solve a similar problem with external tools and I thought that automation would do such things by default “in a box”.
In general, such scenarios are one of the most efficient for large amounts of data with a large number of intermediate calculations.
What restrictions can there be or are there now on looped scenarios?
The other day I wanted to solve my problems on the basis of automation.

We do plan to add support for looping over a set of rows inside a process in the future.

Currently you can process a set of rows using the for each attribute in “Scheduled” events. In this case the process that is selected in the bot will execute N times, where N = the number of rows in the selected table.

@prithpal A scheduled event does not work for my user case, where as part of a governance function someone is setting controls based on products that match a specific search criteria. Therefore for each matching product I have to create a new Control in the intermediary table Product_Has_Control. Hence the loop element.

I have previously implemented the loop using actions as per the comment from @MultiTech_Visions, which works. However I was hoping to use the new Automation feature as it is a little easier to comprehend what’s going on and possibly maintain going forward.

Is using Automation for loops now viable?

Hi @prithpal as mentioned in my previous post, using the scheduler-event as outlined above just does not work for my use case. Dishearten to see the ability to create new Workflows has been disabled; I assume in readiness to switch-over to Bots.

However since the Automation I have seen does NOT support loops, why has the ability to create new workflows been disabled?

See screen-shot below of the disabled new Workflow rule

Automation is a superset of workflow rules. Whatever works in workflow rules is supported in Automation.

Loops “are” supported in Automation just as they were in workflow rules via the “ForEach” option in the Scheduled Event.

What we were discussing earlier in the thread it that we are considering supporting loops “inside” a process → this was never available within workflow rules to begin with.

Hi @prithpal do you have an eta on loops inside a process via Automation? I’ve implemented every version of loops using various workarounds posted by members of the community and they are surely less efficient than an official implementation would be.

We are also using webhooks but they have their own problems requiring the app to be online and execute a sync before the changes show up on the client. A loop/ForEach action that could be executed offline like other data change actions that would be the ultimate feature.

Having a proper loop/ForEach feature as an action, that could also be called by a process is my number one ask. It is the main thing that would make our lives easier and make Automation a joy to use. It would also clean up the huge amount of workaround actions and/or workflows that many of us currently have.

**Edited for clarity and to specify loop/ForEach action that can be used offline and instantly client-side.

APiCC_Conor:

We are also using webhooks but they have their own problems requiring the app to be online and execute a sync before the changes show up on the client.

This true too for any solution that uses Automation.

Steve:

APiCC_Conor:> > > We are also using webhooks but they have their own problems requiring the app to be online and execute a sync before the changes show up on the client.> > This true too for any solution that uses Automation.

You’re right. I guess the more specific request would be to have a loop/ForEach function available as an action.

@prithpal as you can see in the below examples an astronomical amount of work has gone into working around the lack of a loop/ForEach action. A proper new action would also lower the barrier for entry in Appsheet. It took me a long time to understand these posts well enough to implement critical features in our apps.

[Looping with Actions (Sample App BUILD Video)](https://community.appsheet.com/t/looping-with-actions-sample-app-build-video/40187) Tips & Tricks ?

There have been many posts about this topic, I thought I would throw one out there showing the creation of a sample app… from start to finish. This way you can follow along if you want, and hopefully end up at the same place I did at the end of the video. (^_^) Here is a link to the app produced in this video (if you want to skip to the end) https://www.appsheet.com/samples/How-to-loop-through-a-list-and-create-child-records-for-each-item-in-that-list?appGuidString=87db6a15-2904-41c6-b6a9-dbf9…

[Manupulating Array value (List in Appsheet) using LOOP actions](https://community.appsheet.com/t/manupulating-array-value-list-in-appsheet-using-loop-actions/39515) Tips & Tricks ?

Being inspired by @steve s LOOP actions tips and tricks, to add arbitrary number of childs records, I came up with ideas to manupilate values in array, which means list values in Appsheet. User select and/or add values to Enumlist type fields then convert those values as we want. In this simplified sample app, we select and/or values to enumlist, which represents the name. Then we add the string (text) at the end of each listed values to generate the converted list values. In oth…

[Looping with actions](https://community.appsheet.com/t/looping-with-actions/25379) Tips & Tricks ?

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-8c39-b322e1c12da6

[Add any number of rows from any row within a table](https://community.appsheet.com/t/add-any-number-of-rows-from-any-row-within-a-table/22869) Tips & Tricks ?

Definitely a frequently-asked question: how do I add some number of rows to a table automatically? It’s possible, but it’s not easy. This article details an approach that can be accomplished entirely within AppSheet (no API use), within the app itself (no workflow use), and accommodates an arbitrary number of rows (no built-in count maximum). While I’ve tried to make the guide accessible for less-experienced app creators, make no mistake: this is an advanced technique. I hope you find this us…

[FAQ: add row per value in EnumList](https://community.appsheet.com/t/faq-add-row-per-value-in-enumlist/30953) Tips & Tricks ?

Add one row per value in an EnumList column list. Try the sample app! For this example, the table from which the row-addition process will be initiated is called Control Table. The table to which new rows will be added is called Target Table. Use your own names as you see fit. Note that they could even be the same table. Control Table must allow updates; Target Table must allow adds. Control Table must have at least two columns for this process: EnumList (type EnumList; a list of Enum values;…

And my every single app have lopping action that works with workflow. Sadly It is very unfortunate right now for someone who is working with developing applications for manufacturing companies.

Sometimes I have 5 rows to 15 rows to be added to another sheet using looping action. When a 3 row is added on an average its 30 rows. If it’s an action it takes atleast 1-2 minutes to complete the sync. The users use the app and they update everything faster. If they update or add like 3 orders that contains 3 products it would be approx. 90+ rows each time to be looped. That is not at all feasible if I use Looping action. Disappointed with the current update !

I agree totally with with the comments from @APiCC_Conor and @Rifadm817. AppSheet is a great platform to work with, but appears to be missing an important construct enabling Loop capability both instantly on the client-side and in the background, server-side.

I have tried 3 of the suggested work-arounds, with limited success. For my use-case: to use the Scheduled Event it would have to poll for updates every few minutes, 24/7, which cannot be an efficient approach.

Now attempting a 4th solution iteration removing dereferences for Select statements as suggested by @Steve in an attempt to speed-up the ‘loop’ updates.

Just so I understand:

→ this was never available within workflow rules to begin with.

So a workflow could not call an Action that executed a series of steps Correct?

That is what I was going to attempt before the Workflow got disabled in favour of Bots.

Just to add here is a screen-shot of the ‘new’ Bot.

The Repeat Member add does the following:

  1. Repeat member add task

    • calls → Loop (repeater) Action | Create ProductGroup Member
  2. Loop (repeater) Action | Create ProductGroup Member

    • calls → Loop Action | Create ProductGroup Member
  3. Loop Action | Create ProductGroup Member

    1. calls → Action | New 1st group member then
    2. calls → Loop (repeater) Action | Create ProductGroup Member (step 2)

@prithpal Would like to know if it is possible to trigger recursive actions from within a Bot?

Steps 2, 3.1 and 3.2 check there are remaining_members left to process.

Would welcome your thoughts.

No news regarding calling a recursive action within a Bot. I also have a call out with the development team. Any ideas? @prithpal

Wendy would you be able to describe what you mean by recursive actions ?

In workflows and bots DataChange actions invoked by Workflow rules do not trigger other workflow rules or bots.

Hi @Dan_Bahir apologies for the delay, was an AL.

A good example is given above in the screen-shot. In this instance products that belong to a group have to meet a specific criteria. Once identified, a record is created in an intermediary table called: ProductGroup_Has_Member

These records need creating to maintain the many-to-many relationship between ProductGroup has many products and a Product can belong to many ProductGroups.

The trigger is saving the details of a ProductGroup which may have amended the criteria. Hence the start condition: Check | Product group members to add

In the detailed outline of this discussion is mentioned looping over a list of ‘something’ until that list has been processed. Since there is no LOOP construct in AppSheet, we have to make-do with Actions calling each other. The recursive actions are outlined again below:

  • Loop Action | Create Product Group Member calls →
    Add | First Product Group Member
    Loop (repeater) Action | Create ProductGroup Member*

The action: Loop (repeater) Action | Create ProductGroup Member calls → Loop Action | Create Product Group Member hence creating the recursive loop.

But, as explained earlier, doing this on the client-side is too slow as it temporarily freezes the SAVE action, meaning the user has to wait for some of the processing to have been completed, before the using the app further.

Hence the question asked here: about placing this in a Bot, so it can be used server-side. Having tried most of the solutions outlined, still not found one that works without issues for maintaining a many-to-many relationship. Never got an answer from AppSheet as to what is the recommended approach for dealing with many-to-many relationships. I am sure there are lots of AppSheet community members who would like an answer to that question.