
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 09:44 AM
I have a user registration form in that I mentioned email id as my mandatory field. say I am entering the user details with email
Id.
so for that I wanted to use a client script or glideAjax which will be used for restricting of entering the same email id again.
so what script I use for that??? does bussiness rule will be helpful in this case?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 10:06 AM
Hi Saurabh,
As promised, here is the code.
Client Script : I've done validation on submit. However you change as per your req.
function onSubmit() {
//Type appropriate comment here, and begin script below
var userEmail = g_form.getValue('u_email');
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name','helloWorld');
ga.addParam('sysparm_user_name', userEmail);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer == 'true')
{
alert('Email already exists');
}
}
}
Now create a script include:
Name : HelloWorld
Client Callable : True
Script :
var HelloWorld = Class.create();
HelloWorld.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld: function() {
var answer = 'false';
var usrEmail = this.getParameter('sysparm_user_name');
var gr = new GlideRecord('sys_user');
gr.addQuery('email',usrEmail);
gr.query();
while(gr.next())
{
answer = 'true';
}
return answer;
},
_privateFunction: function() { // this function is not client callable
}
});
Also I've developed this on below demo instance.
https://demo007.service-now.com/login.do
Username : admin
Password : admin
Steps for testing : go to Incident form there I've created an email field. Onsubmit of the form it will validate and give an alert.
Please change the naming conventions and modify the script as per your req.
If this answers your question, please mark it correct and close the thread.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 10:18 AM
thank you very much for your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 10:29 AM
You are welcome.
Can you please mark the response as correct if that answers your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 10:38 AM
hello pradeep which function should I use for client callable as you mentioned this function is not client callable.I want this to be client callable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 10:38 AM
It is client callable only.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2015 10:40 AM
ohk fine