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

ClearCollect only works correctly on second click

Hi, I have built an app the uses clearcollect() - this also includes addColumns which is adding a column based on a custom connector to retrieve distance and duration data from google matrix api.

I have had no issues with small data sets - this being dataverse

However, with large data it seems as though i have to click the button twice for it to retrieve the correct data and display on the gallery with the correct distance and duration otherwise it shows the incorrect data.

4 REPLIES 4
rsaikrishna
Super User
Super User

@Anonymous 

 

How large the data you are referring when you are having the issue?

 

Do you see any delegation warning (blue line under the formula)? 

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.
Anonymous
Not applicable

There are no delegation warnings. It seems to work correctly when clicking the button again, this is not ideal for users.

@Anonymous 

 

When you click the button, set a context variable to disable the button and re-enable the button as soon as the clear function completes.

 

Example:

Button control: btnClearCollection

Button's OnSelect:  UpdateContext({varDisableButton:True});ClearCollect(<your code>);UpdateContext({varDisableButton:False});

Button's DisplayMode: if(varDisableButton, DisplayMode.Disabled,DisplayMode.Edit)

 

I think ClearCollect may be taking sometime to clear out the values. 

 

With above test, we can see if the button is disabled while clearing the collection or not. 

 

Try above approach and post here if you have any comments.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

 

Anonymous
Not applicable

  • Hi, this would have worked. However I should have mentioned, my collection is based off a initial gallery items, this initial gallery is connected to cds /data verse and is filtered via a combo box. Add columns is then used on the collection which is connected a Google maps api connector to retrieve distance and duration  and the collection is passed to a second gallery. I think what is happening is that, every time the user selects an item from the combo box the first gallery starts to load and retrieve the data to add to the first gallery. When the user then clicks the button for the collection, the first gallery is still retrieving data, hence the collection is not showing data properly. How do I disable the button until the first gallery has finished retrieving data. 

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 (1,788)