cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Saving to a collection with toggle starts before user i done editing column

Hi!

I'm using a collection for my gallery source and automatically saves changes when user is editing a column. Then I have a button outside my gallery that saves that collection to my datasource (SQL)

I'm using this method as it is much faster and smoother than ForAll with Patch. This took way too long and was annoying for the user. 

 

Now I have a different issue that I'm trying to solve. 
I've set my toggle OnChange to 

Patch(
My_collection,
ThisItem,
{Column1: Value(Label1.Text),
Column2: Value(Label2.Text)
}
)


And my Defualt to:

ThisItem.Column1 <> Value(Label1.Text) ||
ThisItem.Column2 <> Value(Label2.Text)

 

This works great, however my Patch often starts before the user is able to complete the input. This Is fairly annoying. 
Wondering if anyone has any solutions to this?

I've been considering maybe a timer, but not sure how to exactly implement that. Any other, hopefully easier ideas?

 

Thank you so much!

1 REPLY 1
RandyHayes
Super User
Super User

@Anonymous 

Chances are that you were using your ForAll wrong and backward before.  ForAll is a function that creates a table of records, it is not a ForLoop like in development languages.  When used like a ForLoop in PowerApps, it almost always leads to performance issues.

In general, your save formula outside of the Gallery should be similar to this:

Patch(yourDataSource,
    ForAll(yourGallery.AllItems,
        {ID: ID,  //or the name of your primary key to replace ID
         Column1: Label1.Text,
         Column2: Label2.Text
        }
    )
)

 

In your current scenario, you are not providing details about how and when you are storing the data to your datasource, only to collections.  But, keep in mind that a lot of controls will perform their On... actions differently than might be expected and can lead to mysterious results.

 

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!

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.

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 (2,998)