In this blog we will learn how to display the loading screen while performing asynchronous call and we will also add a delay before refreshing data so we can see modified data in Canvas App.
Scenario:
In Canvas App while doing asynchronous actions like MS Flow, Third-party API calls, Asynchronous plugin, or background workflows we have a little delay in fetching the modified data from our Data-source.
In my previous blog, I have explained how to invoke HTTP requests from Canvas App to close the opportunity as Won/Lost. Please have a look Blog Link
Solution:
To overcome this issue we can use the Timer component, Using Timer we can add a small delay before refreshing Data-set, by using this small delay we can fetch recently modified data. during this delay we can also display “Loading Screen” popup to users, so that they can understand some background work is in process.
In the below gif, on the 1st page I am displaying a list of opportunities and by selecting one opportunity I am navigating to the opportunity details page. To make it as won I am calling MS Flow on click of “Won” button. As I said it takes some time to process HTTP calls so for that time I display a loading screen for 5 sec and then refresh the data to get recently modified data.
Please follow the below steps to achieve this functionality.
Step 1: Insert “Timer” Component in your Canvas App.
Step 2: Setup below properties of Timer component.
Step 3: Now we need one loading screen image, just navigate to Media and select “Image” as shown below.
Step 4: Add loading GIF file from your local machine. (you can download any related Image from internet)
Step 5: Set the visible property of the image as a “DisplayLoadingScren” variable. Based on the variable value it will be displayed or hidden.
Step 6: As we are calling our Power Automate (MS Flow) on click of the Won button, start the timer at the same time. Set StartTimer variable value as True using this formula “Set(StartTimer, true)” and Timer will get a start. As soon as it starts our loading image will be displayed.
All set. Now on the specific action you will get a loading screen and after a while the form will bet refreshed with modified data.
Check out related blog post: