I have an action in a set of row with a loop that when the list of rows to repeat is too long, the app stays without doing anything and collapses
I did an action that only appears under certain conditions in the detail view, once the action appears when it was executed the application hangs if there are many rows to execute
When it was executed with few rows it executes perfectly (approx 100 rowa) but if it exceeds 300 rows it hangs and does not work.
This action is configured with a loop that repeats itself until a condition is met and stops repeating.
What can I do?
In my experience, a loop that causes the app to crash is commonly caused by a loop condition that always returns TRUE
, so the loop never stops. Carefully review your loop condition and consider whether it may not work as expected when the number of rows is large.
Another possibility is your loop is producing too many new rows. If each pass through the loop produces (for instance) 5 new rows, 100 passes through the loop will produce 500 rows, where 300 passes through the loop will produce 1500 rows. That large number of rows will require more memory and slow the app.
Yet another possibility is the loops is operating on the rows it’s adding, such that each added row causes even more rows to be added.
It seems to me that the problem lies in the second option that you raise where the loop generates new rows and fails due to memory, is it possible to correct this?
Sure, but the fix is entirely dependent on your app and the logic you use in the loop. You need to construct your loop to skip the newly-added rows.
I’ll show you how I built it to see if you can help me:
This first is the one that makes the loop repeater:
This is the sequence of actions that the loop will do:
And the record that makes the loop:
In addition, there is also a bot that validates if one of the records is greater or less than zero to record part of the information in a third table.
Thanks a lot for your time
I’m afraid you’ll need someone to look deeper into your app than I’m prepared to do.
@Rafael_ANEIC-PY, might you be able to help here?
Sure @Steve, let’s see what can I do hehe
@Inventarios_FOODis I see you have some potentially very expensive formulas in your action that adds new rows, we should start from there, could you share some more information about those and your column structure so we can see if we can improve those expressions?
EDIT: I mean the expressions belonging to “Cantidad Real” and “Cantidad Ajuste”
Once we squeeze a bit of performance out of those, we can evaluate if we need to impose a limit on how many rows your loop grabs at once, we can do that using a slice and an auxiliary column, but more on that later.
Also, what does your third action in your sequence do?
The bot won’t be a problem tho, those are run in AppSheet servers.
User | Count |
---|---|
17 | |
11 | |
7 | |
5 | |
5 |