cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alex93jansen
Helper II
Helper II

How to check if data source is refreshing?

I have a PowerApp which lets users, who do partial WFH, book a specific desk at our office for a specific day. Records are stored in a Sharepoint List. The App displays all desks on a map, with a color indicating the status of each desk (booked, available for booking). If a desk is already booked, users cannot select the App's booking button. No issues here.

 

When a user books a desk, the Sharepoint data source is immediately refreshed to reflect the new desk status (available for booking > booked). However, in some cases this can take 20-30 seconds. In this situation, a user will book their desk, not see the change reflected on their screen right away, and believing there is an error will repeatedly attempt to book the desk.

 

So I need some way to disable the App's booking status, while data is still being refreshed. There already are a couple of other things I'm doing to discourage users (e.g. the button can be selected max. once every 10 seconds and there's UI feedback if the booking was successful). However, some users still continue to repeatedly use the button.

 

I could not find any information however on how to check if a data source is in the process of refreshing.

 

1 ACCEPTED SOLUTION

Accepted Solutions

With that additional info about your app, using an internal collection makes more and more sense. Use your datepicker's OnChange to ClearCollect a filtered table using the selected date. Then, switch your desk color and "booked" lookups to refer to the internal collection. That will turn 80 external queries into one external query and 80 internal ones. With the way you are passing off parameters to variables and then on to a flow, there should be no other wrinkles from using the collection.

 

That said, the validation you are doing with the flow can be done internally with the app. If you're still experiencing delays, consider changing that functionality.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

8 REPLIES 8
BCLS776
Super User
Super User

There are a few things that could help in your situation, but 20-30 seconds for what sounds like a simple data source update seems unusually long.

 

First, open a Monitor session while your app is running to see all clicks and data operations with timestamps. This may show you where the delay is really happening.

 

Next, if you are using the form control, use some code to disable your submit button at OnSelect, and then enable it using the OnSuccess or OnFailure property. That will effectively lock the button until the app receives some sort of expected result. If you are using Patch() to make the changes, use the return from that function to similarly control the displaymode of the button.

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

The 20-30 seconds delay only happens in about 20% of cases; usually, the data refreshes pretty much instantly.

 

However, each gallery item (desk) features two queries (one to display the desk availability status, one to display the booked user's name) and so the Monitor shows about 400 events per data refresh. Usually each event is executed in 150-200ms, but in some cases across the board they will all take 10+ seconds.

 

I suppose I should re-design my App so that it runs the queries only once, store the result in a collection and have the gallery items refer to that instead?

BCLS776
Super User
Super User

Adding a collection into the mix may only add complexity and slow your app down further. Instead, walk us through the user experience and underlying logic for the app to see if we can make some suggestions for performance. It'll go something like this:

 

  1. User starts the app
  2. App goes to main screen with the desk gallery. Desk gallery filter shows only those desks that are available that day.
  3. User browses and presses the button next to the desk they want to book. Button executes a SubmitForm() to change the Status column to "Booked" and the BookedBy column to the current user.
  4. User receives a Notify() through OnSuccess that the desk was successfully booked
  5. App refreshes the gallery in case the user wants to book a second desk
  6. And so on...

Your UX is probably different, so can you describe yours?

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

alex93jansen_0-1630886634962.png

This is my PowerApp. Currently the user uses the App as follow:

 

(1) User loads the PowerApp

(2) User selects a date using the DatePicker in the top left (default set to current date)

(3) The desk map will update accordingly (green = bookable, red = already booked, grey = not bookable)

(4) User selects any desk from the map. This will update the 3 fields on the bottom left (Desk name, User who booked it, Department of user who booked it)

(5) If the desk is bookable, the button will read "Confirm Desk Booking", which triggers a PA Flow. The PA Flow will validate a few things, and insert a record into the List

(6) The data source (Sharepoint List) will refresh after a user has booked, to reflect their booking in the PowerApp

(7) User will receive an email after booking, showing whether or not their booking was successful

 

Each desk on the map (40 desks in total) has a query for the color and name of person who booked it (displayed on the map if person is in the user's Department, hidden otherwise). This ends up totaling almost 400 entries in the Monitor each time date is refreshed, as the queries feature multiple (delegatable) functions.

First of all - love the map view for booking desks! That must make it very easy for users to choose the desk they want.

 

Two things that I'd look at closer for performance:

  • What is/are the underlying control(s) here? Are the desks actually part of the form, or are they buttons that set the values that will be the update values for the form that is only the left-most portion of the screen? Is each desk's fill color done through a separate LookUp() operation? If so, that will cause refreshes to take time to execute.
  • The PA flow mentioned in Step 5 - is there any way to "validate a few things" and create the record right in your app? Flows don't always execute instantaneously, depending on service availability.

I think you bring up a good point on the number of queries being performed - Microsoft governs the Power Apps service levels so that performance is predictable for ALL users, so they limit how many API calls can be performed within a certain unit of time. This prevents a few users from "hogging" the service at the expense of others. In the case of Sharepoint, Microsoft throttles the connector to 600 API calls per 60 seconds. Want to bet some of your problem lies there? You figure already you are hitting 400 calls per refresh.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

The desks are simply icons part of a Gallery, which set variables (deskNo, deskName) when selected. When using the Confirm button, "deskNo" will be submitted along with User().Email and datepicker.SelectedDate to the PA Flow. The PA Flow will then confirm no booking yet exists for the selected date + desk, or selected date + user (users cannot book more than 1 desk per day).

  • Yes, each Gallery item (desk) has several LookUp functions
  • There is no particular reason I went for a PA Flow, other than I just didn't have to worry about data refresh issues causing problems for the validation (e.g. multiple users could be booking the same desk at the same time, so it can't be query'ing old data). Anyway, so far I have not encountered any issues with Flow execution, so this topic would be of lesser concern for now.

 

What would be the best way to reduce number of queries? I can probably optimize some parts, but at minimum each desk would still require 1 query for the color, and one query to display person who booked it. 40 desks x 2 queries = 80 queries per refresh. Users may submit bookings for multiple days at the time, so will use the date picker repeatedly, which re-queries data and leads to a high query count. Both the desk color + booked person's name are key functionalities that must be present in the App.

With that additional info about your app, using an internal collection makes more and more sense. Use your datepicker's OnChange to ClearCollect a filtered table using the selected date. Then, switch your desk color and "booked" lookups to refer to the internal collection. That will turn 80 external queries into one external query and 80 internal ones. With the way you are passing off parameters to variables and then on to a flow, there should be no other wrinkles from using the collection.

 

That said, the validation you are doing with the flow can be done internally with the app. If you're still experiencing delays, consider changing that functionality.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

Thanks, I'll give your suggestions a go this week 🙂

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,340)