onSubmit client catalog script issue to stop submitting the form based on GlideAjax XML response
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2025 12:04 PM
Hello, I have a requirement where I need to submit form based on the response from GlideAjax XML response in catalog client script. Here is my code :
function onSubmit() {
alert(g_form.getValue('type_of_ser'));
if(g_form.getValue('type_of_ser') === 'I want to travel out of country and require access to Microsoft apps.'){
var ga = new GlideAjax('CheckDuplicateRequest');
ga.addParam('sysparm_name','checkDuplicate');
ga.addParam('sysparm_requested_for',g_user.userID);
ga.addParam('sysparm_request_type',g_form.getValue('type_of_ser'));
ga.addParam('sysparm_start_date',g_form.getValue('begin_date'));
ga.addParam('sysparm_end_date',g_form.getValue('end_date'));
ga.addParam('sysparm_country',g_form.getValue('travel_to_country'));
ga.getXMLAnswer(function (response){
alert(response);
if(response == 'true'){
g_form.addErrorMessage('Duplicate Request exists for same dates.');
return false;
}else{
return true;
}
});
//alert(answer);
}
}
Please give me any valid solutions for this type of situation.