Using If expressions in templates
Conditionally include or exclude portions of a template using If expressions.
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.
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.
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.
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:
Repeat member add task
Loop (repeater) Action | Create ProductGroup Member
Loop Action | Create ProductGroup Member
@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:
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.
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*
If you already have a set of Actions executing the desire loop you want, you should be able to trigger a Data Change process that executes the same Action loop. That would force those actions to run on the server side within the scope of the process.
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.
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.
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.
@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.
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-i...
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โฆ
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...
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โฆ
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.
Hi Wendy,
We currently do not have a good solution for this use case. In our road map we are planning to introduce a for each step that would allow to provide an expression that would return a list of rows which then you could execute a series of steps or a sub process on.
In the mean time we will expose the โExecute an action on a set of rowsโ and โExecute a sequence of actionsโ actions that in combination might allow you to implement the looping you want.
Just wanted to add that I have the same issue here.
Iโm fairly new to Appsheet (just a few months use) and while I was initially impressed with what could be achieved in a short amount of time, I now keep running into roadblocks caused by the lack of very basic functionality, particularly in Appsheet Automation.
I can understand Appsheet wanting to keep things as low-code/no-code as possible, but this shouldnโt mean ditching basic functions such as iteration (โforโ and โwhileโ loop equivalents).
EDITED: Moved my list of issues to a new topic here since most of them werenโt related to looping
I am new to AppSheet and am struggling to automate the creation of tasks for a related request upon request submission. Please see the attached flowchart for the desired behavior. I thought this would be an easy ask, however, upon Googling examples of Event triggered loops in AppSheet I was distraught to find this community post about how this functionality appears to be completely lacking.
Can someone assist me with a workaround, please?
Can someone assist me with a workaround, please?
Sure! First, a caution, this past week an issue surfaced (I think a bug) where iterative actions from a Bot only processed the first row. The same action set, activated on Form Save behavior, processed all rows as expected. So, I would advise to begin implementing the below on the Form Save behavior when entering a new Request. This will avoid any potential bug while creating the process and there is no lost effort this way.
Here is the looping construct I would create. It takes advantage of a recursive call ability to repeat adding Task rows WHILE there are still Categories that have NOT been added to a Task. The Steps are:
1) Create a looping control action. It basically starts off the recursion but has the check as to WHEN to stop looping. It looks like the below image - wait to add the Reference Action. Thatโll be done in a later step
The critical part is the Behavior criteria that allows the action to run and stop. I used this expression:
COUNT(SELECT(Categories[Category ID], NOT(IN([Category ID], Select(Tasks[Category], [Request] = [_THISROW].[Request ID]))))) > 0
2) Create the action that adds the Task Rows. See below.
To assign the Categories, the action simply picks off the first one in the list of Categories that have NOT yet been assigned to a task for this Request. No Behavior criteria on this one.
ANY(SELECT(Categories[Category ID], NOT(IN([Category ID], Select(Tasks[Category], [Request] = [_THISROW].[Request ID])))))
3) Create a Grouped Action that calls the action to add the Task Row and then calls the โtopโ action to loop again. It looks like the below and no Behavior criteria.
4) Add the Grouped action from 3) to the action in 1) as the Reference Action.
5) Attach the action in 1) to the Form Save behavior and Test!
Here is an example run
Categories are:
No Requests or Tasks:
Add a Request. Immediately switching to the Tasks view shows all rows there while updates are still being made to the server. See image.
If your use case requires the use of a Bot, simply add the โloop controlโ action to the Process Step and you are good to go!!
I hope this helps!!
If your use case requires the use of a Bot, simply add the โloop controlโ action to the Process Step and you are good to go!!
Good news!! I created a Bot and attached the above action set and all the expected rows were created. Either the issue I mentioned is only for certain use cases or it has been fixed.
Thank you so very much for taking the time to mock this up and create a tutorial for me! This worked brilliantly and did exactly what I wanted! I am floored by your speedy yet thorough high quality response. I learned a lot from studying all of the steps you provided. Your instructions were very easy to follow with your screenshots and code boxes.
Is there a way to loop through a list and fire workflows? For example, letโs say I have clientโs A, B, and C. Every week I want to send them an email with a list of their outstanding bills. Currently I have a different email template for each client, however, itโd be a lot easier to have one template that I can use for all clients. Does anyone know if this is possible?
Currently I have a different email template for each client, however, itโd be a lot easier to have one template that I can use for all clients. Does anyone know if this is possible?
Yes, it is. In templates we can insert IF/END
blocks so you can conditionally control the appearance of sections in the template based on criteria such as [Customer] = "XYZ"
.
Conditionally include or exclude portions of a template using If expressions.
Putting everything in a single template can cause the template to be overwhelming to maintain if it gets overly complicated.
One way to combat this is to find template info that can be pushed into the customer table as variable data. This is normally some static text that is customized for each client and when in a dedicated template can just stay in the template.
BUT, once you centralize the templates, you find a number of different custom info, messages, etc per client. Place these into the customer table as template customization variables. Then in your template you donโt need a long list of `IF/ENDโ blocks, you just simply show the table column info as a template variable. Some of the customer data may simply be blank and thatโs okay.
This is great. Thanks for your response!
User | Count |
---|---|
43 | |
29 | |
22 | |
20 | |
15 |