How can i validate if the emails are valid or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-24-2022 05:35 AM
Hi,
Below is my requirement.
if user enter data in multiline text is - abc@gmail.com,efg@gmail.com,abc@yahoo.com
before creating the RITM i need to validate the emails available in user table or not.
if not i need to display error related to the count of how many of them not correct and what are the email's are wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-24-2022 05:52 AM
Hi @Emp 53 ,
How are you going to enter email ID on multiline text ? Is it one at a time or many at a time by comma separated ?
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-24-2022 05:53 AM
many at a time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-24-2022 06:46 AM
create onchange catalog client script as below: select proper catalog, field name and ui type
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getCallerDetails'); //Scriptinclude
ga.addParam('sysparm_name', 'getDetails'); //Method
ga.addParam('sysparm_email', newValue); //Parameters
ga.getXML(getResponse);
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("Email ID's Already Present :"+answer);
}
}
Script Include :-
var getCallerDetails = Class.create();
getCallerDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDetails: function() {
var currentEmail = this.getParameter('sysparm_email');
var arr = currentEmail.split(',');
var alreadyPresent = [];
for (var i = 0; i < arr.length; i++) {
var gr = new GlideRecord('sys_user');
gr.addQuery('email', arr[i]);
gr.query();
if (gr.next()) {
alreadyPresent.push(gr.email).toString();
}
}
return alreadyPresent.toString();
//return alreadyPresent;
},
type: 'getCallerDetails'
});