
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2018 04:01 AM
Hello All,
I am new to GlideAjax and trying to check duplicate email address on a catalog form. I am getting "Failed to load resource: the server responded with a status of 404 (Not Found)" on submitting the form because of the script include and catalog script running in the background. Can anyone help what mistake I am making here?
-----------------------------Script include: "Name: EmailIDDuplicate" ---------------------------------
var EmailIDDuplicate = Class.create();
EmailIDDuplicate.prototype = Object.extendsObject(AbstractAjaxProcessor,{
duplicatecheck : function()
{
var email_ajax = this.getParameter('sysparm_a2');
var gr = new GlideRecord('sys_user');
gr.addQuery('email','email_ajax');
gr.query();
try
{
if(gr.next())
{
alert("Alert box of script");
return true;
}
else{
return false;
}
}
catch(err)
{
gs.log("Error is : "+err);
}
},
type: "EmailIDDuplicate"
});
---------------------------- Catalog client Script------------------------------
function onSubmit() {
//Type appropriate comment here, and begin script below
var email_value = g_form.getValue('email');
var ga = new GlideAjax('Email ID duplicate check');
ga.addParam('sysparm_a1', 'duplicatecheck');
ga.addParam('sysparm_a2', 'email_value');
ga.getXMLAnswer(checkemailResponse);
function checkemailResponse()
{
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'true')
{
g_form.showErrorBox("Duplicate email");
g_form.setValue('email','');
}
else
{
return true;
}
}
}
Regards,
Kopal
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2018 12:12 PM
Do you need the solution to support the Service Portal? If not, then you can do it right in the onSubmit() Client Script:
function onSubmit() {
var emailAddress = g_form.getValue("email");
var gr = new GlideRecord("sys_user");
gr.addQuery("email", emailAddress);
gr.query();
if (gr.next()) {
g_form.showFieldMsg("email","Found an existing User record with the same email address", "error");
return false; //abort the submit
} else {
return true; //carry on
}
}
GlideAjax and onSubmit scripts do not really go together, as the result from the Script Include would normally arrive back at the client after the submission was completed and moved on from the form so the answer could not even be evaluated.
Because the check is happening on submission, the user is no longer interacting with the form, so there is no need to use an Ajax call. They are just waiting on the submit to finish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2018 11:36 PM
Did you find a solution to your issue? If yes, please remember to tag the correct answer and any that were helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 02:41 AM
Hi Jim,
Thank you for your follow up and response on my question.
Regards,
Kopal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 07:38 AM
You are welcome.