cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
efroseroc
Helper III
Helper III

Hold user until formula stops calculating

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

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

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.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
RandyHayes
Super User
Super User

@efroseroc 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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.

RandyHayes
Super User
Super User

@efroseroc 

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})))
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,999)