web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Overlay with a spinner on a form while field validations are in progress.

(0) ShareShare
ReportReport
Posted on by

Hi,

Recently, I had to work on a task which includes many field validations and Ajax calls that took a lot of background processing time and I had to stop the end user from taking any other actions like saving or submitting the form. To say, stopping all basic form actions. To achieve this, either I have to disable all form actions or show an Overlay on the page. In my case, the second option is the best. 

While researching, I found that there is no OOB functionality in MS Dynamics CRM for this, like calling a method to mask the page and unmask whenever it is not required. So, I have developed a generic function in JavaScript which can be used for both Show and Hide the overlay. Of course, with the default CRM loading spinner. And it is working with the latest version of CRM too.

Below is the screenshot of the end result.

Mask.JPG

And, below method can be used to achieve it.

function ToggleLoader(ShowOverLay){
	var CRMTopBar = top.document.getElementById("crmTopBar");
	var divOverlays = top.document.getElementById("divOverLay");
	if(ShowOverLay){
		if(divOverlays == null && CRMTopBar != null){
			var divOverlay = document.createElement('div');
			divOverlay.setAttribute('id',"divOverLay");
			
			divOverlay.style.textAlign = "center";
			divOverlay.style.position = "absolute";
			divOverlay.style.top = "0px";
			divOverlay.style.left = "0px";
			divOverlay.style.bottom = "0px";
			divOverlay.style.right = "0px";
			divOverlay.style.zIndex = "100";
			divOverlay.style.backgroundColor = "rgba(0,0,0,0.4)";		
			var imgSource = "<img id='loading' src='/_imgs/AdvFind/progress.gif' style='text-align:center; position:absolute; top:50%; left:50%; right:0px; border-radius: 10px; background-color:white;'>"; 
			divOverlay.innerHTML = imgSource;
			divOverlay.style.display = 'block';
			CRMTopBar.parentNode.insertBefore(divOverlay, CRMTopBar); 
		}
	}
	else{
		var hideDivOverlays = top.document.getElementById('divOverLay');
		if(hideDivOverlays != null){
			hideDivOverlays.style.display = 'none';
		}
	}
}

I have inserted the newly created dynamic div before the "CRMTopBar" which contains the Form basic actions.

To show the overlay, JS method should be called with parameter either 1 or True and to hide, with 0 or False.

  • Show Overlay: ToggleLoader(1); or ToggleLoader(true);
  • Hide Overlay: ToggleLoader(0); or ToggleLoader(false);

Hope this helps someone who is in need.

Thanks

Jagadesh D

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at

    You could also use the supported Xrm.Utility.showProgressIndicator in v9 to accomplish the same thing.

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/showprogressindicator

  • Community Member Profile Picture
    on at

    Hi Jason,

    Thank you for your reply.

    I tried that too but using Xrm.Utility.showProgressIndicator didn't stop me from accessing the Form basic actions, which I had to accomplish. I was able to submit my form or create a new record. 

    Screenshot-2.jpg

    Thanks

    Jagadesh D

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Did you try using alert.js?

    I think it does an automatic overlay.

    github.com/.../alertjs

    Hope this helps.

  • urklnme Profile Picture
    439 on at

    FYI: alertjs requires organization to pay for a license

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans