back to top

Modifying the Infor CRM SLX Web Client Email Control’s Input Validation

In a previous blog post I detailed how to extend the Infor CRM SLX email control to have different validation rules about the kind of data that is considered a valid email address. Previously the email control had pretty rudimentary validation, only enforcing there was something before and after an @ symbol. Starting in version 8.5.0 the validation has improved. With this improvement, the way of altering the validation function has also changed from what I had previously documented. Previously the /Model/Portal/SlxClient/SupportFiles/jscript/Sage/UI/Controls/Email.js file itself had a function for the email validation. However in 8.5 the validation within the Email.js file has been removed and the validation now exists in the /Model/Portal/SlxClient/SupportFiles/jscript/Sage/Utility.js. Within the Utility.js file there is a function called emailAddressRegEx which now handles the validation of email addresses. It now validates the data before the @ symbol, and also validates that the suffix or host is valid.

		emailAddressRegEx: function(flags){
			// summary:
			//		Builds a regular expression that matches an email address
			// flags: Object?
			//		- flags.allowCruft  Allow address like `<mailto:foo@yahoo.com>`.  Default is false.
			//		- flags in regexp.host can be applied.
			//		- flags in regexp.ipAddress can be applied.

			// assign default values to missing parameters
			flags = (typeof flags == "object") ? flags : {};
			if (typeof flags.allowCruft != "boolean") { flags.allowCruft = false; }
			flags.allowPort = false; // invalid in email addresses

			// user name RE per rfc5322
			var usernameRE = "([!#-'*+\\-\\/-9=?A-Z^-~]+[.])*[!#-'*+\\-\\/-9=?A-Z^-~]+";

			// build emailAddress RE
			var emailAddressRE = usernameRE + "@" + Sage.Utility.fnHost(flags);

			// Allow email addresses with cruft
			if ( flags.allowCruft ) {
				emailAddressRE = "<?(mailto\\:)?" + emailAddressRE + ">?";
			}

			return emailAddressRE; // String
		},
		fnHost: function(flags){
			// summary:
			//		Builds a RE that matches a host
			// description:
			//		A host is a named host (A-z0-9_- but not starting with -), a domain name or an IP address, possibly followed by a port number.
			// flags: Object?
			//		- flags.allowNamed Allow a named host for local networks. Default is false.
			//		- flags.allowIP  Allow an IP address for hostname.  Default is true.
			//		- flags.allowLocal  Allow the host to be "localhost".  Default is false.
			//		- flags.allowPort  Allow a port number to be present.  Default is true.
			//		- flags in regexp.ipAddress can be applied.

			// assign default values to missing parameters
			flags = (typeof flags == "object") ? flags : {};

			if(typeof flags.allowIP != "boolean"){ flags.allowIP = true; }
			if(typeof flags.allowLocal != "boolean"){ flags.allowLocal = false; }
			if(typeof flags.allowPort != "boolean"){ flags.allowPort = true; }
			if(typeof flags.allowNamed != "boolean"){ flags.allowNamed = false; }

			//TODO: support unicode hostnames?
			// Domain name labels can not end with a dash.
			var domainLabelRE = "(?:[\\da-zA-Z](?:[-\\da-zA-Z]{0,61}[\\da-zA-Z])?)";
			var domainNameRE = "(?:[a-zA-Z](?:[-\\da-zA-Z]{0,252}[\\da-zA-Z])?)"; // restricted version to allow backwards compatibility with allowLocal, allowIP

			// port number RE
			var portRE = flags.allowPort ? "(\\:\\d+)?" : "";

			// build host RE
			var hostNameRE = "((?:" + domainLabelRE + "\\.)+" + domainNameRE + "\\.?)";
			if(flags.allowIP){ hostNameRE += "|" +  regexp.ipAddress(flags); }
			if(flags.allowLocal){ hostNameRE += "|localhost"; }
			if(flags.allowNamed){ hostNameRE += "|^[^-][a-zA-Z0-9_-]*"; }
			return "(" + hostNameRE + ")" + portRE; // String
		
        }

That is a lot of validation. Ultimately what is being returned is a regex expression that the user input is tested against. It the input matches the regex pattern then it is a “good” email address. If not, then the validation fails. Luckily we don’t have to modify all of that code if we don’t want to. Instead we can just replace that function with our own. If we ever want to back ours out then it would revert to the standard validation.

To overwrite the standard function we don’t need to replace or append to the Utility module. We can just override the specific function. The easiest way to do this is to use the Customer FX custom loader and add a new module or script file. Then inside that new file, we simply access the existing Sage.Utility object and replace the emailAddressRegEx function like this:

define([],
	function () {			
            Sage.Utility.emailAddressRegEx = function (flags) {          				                   
                var validationString = ".*";
                return validationString;
            };            
        }
);

This is a very simple example, that returns a regex string that will match anything, which essentially negates any validation of the email control. But hopefully you get the point.

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Kris Halsrud
Kris Halsrud
Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos