Email Validation using script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2025 06:59 AM
I have a problem in domain validation example (aa.com ,bb.com ,cc.com)
i have email field it should only allow above domain name after @ but this requirement should get by script include
Any one please support on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2025 02:36 AM
Hi @rajibosss11,
if you want to achieve it by a script include then the script include must be called as it has no trigger.
Usually it can be called from a (catalog) client script..
Is this email validation in backend or portal form?
- Backend > client script,
- Portal > catalog client script,
- or both > CS a CCS both needed in parallel.
Also, you might want to write an onChange (C)CS to inform user that only defined email is available and onSubmit not to allow them if the condition is not respected.
Perhaps this can be done by (C)CS without having the need of script include.
Or you might be able to do it by (Catalog) UI Policy as well.
Share what you have and what behaviour does it do and we can brainstorm/debug together
No AI was used in the writing of this post. Pure #GlideFather only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2025 02:49 AM
Hi @rajibosss11
you create client script and script include
Create a Script Include that returns the list of allowed domains.
Call that Script Include using GlideAjax from a Client Script.
Validate the email field before saving.
Client script:
function onChange(control, oldValue, newValue) {
if (!newValue) return;
var ga = new GlideAjax('Script include name');
ga.addParam('sysparm_name', 'getAllowedDomains ');
ga.getXML(function (response) {
var domains = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
// Extract domain from input email
var emailDomain = newValue.split('@')[1];
if (!domains.includes(emailDomain)) {
g_form.showFieldMsg('Field Name',
"Invalid email domain. Allowed domains: " + domains.join(", "),
"error");
g_form.setValue('field name', '');
}
});
}
Script include functon:
getAllowedDomains: function () {
// Define allowed domains here
var domains = ["aa.com", "bb.com", "cc.com"];
return JSON.stringify(domains);
},
Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2025 09:59 AM
No its not works