Not allow form to submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2024 08:16 AM
My requirement is to not allow users to submit the record producer form if already same short description and description has been entered in previous requests. I have written on submit client script where i have made a glideajax call in order to receive data from server which is checking whether the incident is having same combination of short description and description so everything is working fine but I am not able to execute return false once conditions match from the existing data and hence in all cases the form is getting submitted.
client script -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 03:50 AM
Thank you for the solution, Juhi. Unfortunately return false is not working here as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2024 11:18 PM
You can give my adjusted client script a try.
function onSubmit() {
/*** Pop this gem into your script! */
if (g_scratchpad.isFormValid) {
return true;
}
var actionName = g_form.getActionName();
var shortDescription = g_form.getValue('short_description');
var description = g_form.getValue('description');
if ((!shortDescription) && (!description)) { //you can just make these variables mandatory
return false;
}
var ga = new GlideAjax('inci');
ga.addParam('sysparm_name', 'fetch');
ga.addParam('sysparm_val', shortDescription);
ga.addParam('sysparm_valu', description);
ga.getXMLAnswer(function(answer) {
if (answer === 'true') {
return false;
} else {
/*** Pop this gem into your script! */
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}
});
/*** Pop this gem into your script! */
return false;
}
Reference:
Onsubmit catalog client script is not aborting the form from submitting
KB0783579 - How to do async validation in an onsubmit client script.
Cheers,
Tai Vu