Hi thanks for reading,
I have an app that creates new records on a SP using For All and patch.
I'm suspecting that if the number of records its too high the user can exit the app when the formula is still running.
I ran a little test and it took 30 seconds to finish and in that time a regular user would expect the process to be over and would close the app.
Is there any way to mitigate this?
Thanks again
The best way to handle something like that is to pass the update off to a Power Automate flow. Then have the return value of the flow update a variable. Until the return variable updates have a label or wait icon visible on the screen to keep the user from leaving. Even if they do close the app the flow should still continue running and finish the update.
I would suggest changing your patch statement. I am guessing from your description that you have a Patch inside of a ForAll. This would be backward and will cause you to have performance issues and take longer to patch than is necessary. So, if you provide that formula, I can review and provide a way to make that happen quicker.
As for users exiting the app, there is no way to stop a user from exiting an app. You can provide a message to the user when they exit. This can be based on some other reference in your app if needed, but your issue seems to be more related to someone exiting while the formula you have is evaluating. So, I would tackle the performance on that to reduce the amount of time it takes first.
I hope this is helpful for you.
ForAll(
MyCollection;
Patch(
'MySPlist';
Defaults('MySPlist');
{
Field1: Column1;
Field2: Column2;
Field3: Column3;
Field4: Column4;
Field5: Column5;
Field6: Form1.LastSubmit.ID;
Field7: Column6
}
)
This is set On Success for Form1.
I'm filling the collection with some controls and showing them in a table.
Thanks for your help.
Yes, so as I assumed, your ForAll is backward. You are using it like a For Loop in a programming language...in PowerApps, ForAll is a function that creates a table. You can then pass that table to the Patch function and then the Patch will only instantiate itself once for the operation. This will improve your performance.
Your formula should be:
Patch(MySPlist;
ForAll(MyCollection;
{
Field1: Column1;
Field2: Column2;
Field3: Column3;
Field4: Column4;
Field5: Column5;
Field6: Form1.LastSubmit.ID;
Field7: Column6
}
)
)
However, if your collection has the exact same column names and datatypes as your datasource, then you can utilize the following instead:
Patch(MySPList, ForAll(MyCollection As _item, Patch(_item, {Field6: Self.LastSubmit.ID})))
User | Count |
---|---|
263 | |
110 | |
92 | |
55 | |
41 |