We will learn to display a progress indicator or loading screen in Dynamics 365 CRM. Before we start, make sure to subscribe to CRM Crate so that you stay up-to-date in field of Dynamics 365.
Why do we need progress indicators or loading screen in Dynamics 365 CRM?
Consider a scenario where we have to perform an asynchronous or time-consuming synchronous operation on Dynamics 365 form where we want our end user to wait until the operation has executed successfully. We can achieve this requirement by displaying a waiting or loading screen during the interval of the operations, this will prevent the user from updating the form in middle of the operation and provide a better user experience.
Using client side JavaScript for displaying the progress indicator –
Below are the Client APIs used for achieving the in-progress indicator in Dynamics 365 CRM forms.
showProgressIndicator (Client API reference)
Xrm.Utility.showProgressIndicator(message)
closeProgressIndicator (Client API reference)
Xrm.Utility.closeProgressIndicator()
The showProgressIndicator (Client API reference) is used to initiate or start the progress indicator screen, we can display any custom string message within the API’s parameter.
The closeProgressIndicator (Client API reference) is used to terminate or stop the previously started progress indicator.
JavaScript Snippet Code –
The below JavaScript function has been called during the “OnClick” event of the form ribbon button. The progress indicator starts on the exeuction of the function and stops after 5 seconds of execution due to the explicitly added timeout as shown below.
//CRM Crate - JavaScript Snippet
function CallMethod (executionContext) {
var formContext = executionContext;
//Start The Progress Indicator.
Xrm.Utility.showProgressIndicator("CRM Crate Progress Indicator");
//Delay Of 5 Seconds.
setTimeout(function(){
//Stopping The Progress Indicator.
Xrm.Utility.closeProgressIndicator();
}, 5000);
}
Thus we learned to display a progress indicator or loading screen in Dynamics 365 CRM.