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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,303)