I have a button that `on select` does this:
However what I noticed is that the `test_collection` gets updated only if I click on the button twice. It never seems to return the correct updated collection within a single click.
Any ideas why?
Just a guess but it may be that the ClearCollect is firing off before Refresh has had a chance to finish. You can test this by replacing your button with a timer control and set the following properties:
If that works you found the problem, then try decreasing the duration until the problem recurs.
Hi @Drrickryp .. I tried and made it wait until 30s but that does not seem to have worked. What I did was create 2 separate buttons: One button just to refresh the database .. wait for 30s and then click on the other button (as in the original post): i.e. a `refresh` before calling `clearcollect`. So basically I am calling refresh twice with a gap of 30s between the refresh intervals.
Not entirely sure why it always works on the second click at a minimum .i.e only if I repeat the above loop twice.
I found this as a problem myself and found that you not always get just inserted/updated records directly back to PowerApps. I don't know why, but I would think this maybe has to do with cashing on the sql side off things. For me this was a reason to go for another setup off my solutions by introducing flow as an interface which calls a stored procedure on the sql server which returns my records to my collection.
If you like to learn how to do this and see if this is an option you could use, see MS PowerApps | SQL Server & Flow
Know there are more advantages in adopting flow then only returning all the records to the collection.
Hope this helps.