cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Powerapprookie2
Helper I
Helper I

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

@Powerapprookie2 

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (917)