Preventing User Clicks During Postbacks with a Shield in the Infor CRM Web Client

When a postback occurs in Infor CRM (Saleslogix), there is a small circular loading icon that appears in the top, title/menu area of Infor CRM. However, for long postbacks, it doesn’t prevent users from still clicking or changing things during this postback. If the user does this, when the postback returns, things they might have clicked or changed will be lost. A simple solution to this is to shield the page during postbacks that will prevent the user from clicking anything while the postback is occurring.

This can be easily accomplished by hooking into the client-side async requests and showing and hiding a shield during these requests. We can use the begin and end request events from the Page’s ScriptManager using Sys.WebForms.PageRequestManager.getInstance(). We’ll also use the build-in loading shield and display this during the postback event.

The client-side Javascript code to do all of this looks like this:

require([
	'dojo/ready', 
	'dojo/dom-style'
], 
function(ready, domStyle) {

	function _fxBeginRequestHandler(sender, args) {
		_setShield(true);
	}
	
	function _fxEndRequestHandler(sender, args) {
		_setShield(false);
	}

	function _setShield(show) {
		var styles = show 
			? {'opacity': '.5', 'display': 'block'}
			: {'opacity': '0', 'display': 'none'};
		domStyle.set('loader', styles);
	}

	ready(function() {
		Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(_fxBeginRequestHandler);
		Sys.WebForms.PageRequestManager.getInstance().add_endRequest(_fxEndRequestHandler);
	});

});

Place the code above into a file and name it something like PostbackShield.js. Then, if you’re using my Custom Loader Module all you need to do is drop that file into the “Custom\Scripts” folder. If you’re not using that module (and really, you should be because it’s so much easier) just add your own <script> tag to load the script to the master page.

Once you do that, any time a postback occurs, you’ll see the shield like this (notice how there is a opaque shield that covers the screen when the save button is clicked):

If you’d like to have a completely transparent shield, rather than the faint opaque shield, just change the line that says this:

? {'opacity': '.5', 'display': 'block'}

to this

? {'opacity': '0', 'display': 'block'}

and it will still shield the content, but the user won’t see or notice anything.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He’s been blogging regularly about SalesLogix since 2001 and believes in sharing with the community. He loves C#, Javascript, Python, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!