Unable to submit form after one click on submit button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 11:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 12:40 PM
@Ashwini raut Please update your script as follows and see if it works,
function onSubmit() {
// Making the checkboxes mandatory for New Zealand users
if (g_scratchpad.isFormValid)
return true;
var gdjUser = new GlideAjax('global.KHCatalogAjaxUtilsNewHire');
gdjUser.addParam('sysparm_name', 'checkNZUser');
gdjUser.addParam('sysparm_hrUser', g_user.userID);
gdjUser.getXMLAnswer(setAnswer);
return false;
function setAnswer(answer) {
if (answer == 'false') {
g_scratchpad.isFormValid = true;
} else {
var a = g_form.getBooleanValue('employment_contract_signed_by_employee');
var b = g_form.getBooleanValue('personal_details_form');
var c = g_form.getBooleanValue('tax_details_form');
if (a == false || b == false || c == false) {
g_form.addErrorMessage("Please check the checkbox for Employment contract signed by employee, Personal details and Tax details");
return false;
}
var actionName = g_form.getActionName();
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
}
}
}
function onSubmit() {
// Making the checkboxes mandatory for Australia users
if (g_scratchpad.isFormsValid)
return true;
var AU = new GlideAjax('global.KHCatalogAjaxUtilsNewHire');
AU.addParam('sysparm_name', 'checkAUUser');
AU.addParam('sysparm_hrUser', g_user.userID);
AU.getXMLAnswer(setAns);
return false;
function setAns(answer) {
if (answer == 'false') {
g_scratchpad.isFormsValid = true;
} else {
var a = g_form.getBooleanValue('employment_contract_signed_by_employ');
var b = g_form.getBooleanValue('personal_details_for');
var c = g_form.getBooleanValue('tax_file_declaration');
var d = g_form.getBooleanValue('super_form_smsf_attach_compliance_letter');
if (a == false || b == false || c == false || d == false) {
g_form.addErrorMessage("Please check the checkbox for Employment contract signed by employee, Personal details, Tax details and Super Form");
return false;
}
var actionName = g_form.getActionName();
g_scratchpad.isFormsValid = true;
g_form.submit(actionName);
}
}
}
Hope this change works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2024 02:41 AM
@Sandeep Rajput Thank you for the response.
I have tried above changes in my script, Still behavior is same. Its allowing to submit form in 3 click only
Could you please suggest more changes in that if required.
Thanks,
Ashwini.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2024 02:48 AM
@Ashwini raut Please check the browser console and see if find any errors when you submit the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2024 07:35 AM
@Ashwini raut Here is an updated script for you.
function onSubmit() {
// Making the checkboxes mandatory for Australia users
if (g_scratchpad.isFormsValid)
return true;
var actionName = g_form.getActionName();
var AU = new GlideAjax('global.KHCatalogAjaxUtilsNewHire');
AU.addParam('sysparm_name', 'checkAUUser');
AU.addParam('sysparm_hrUser', g_user.userID);
AU.getXMLAnswer(setAns);
return false;
function setAns(answer) {
if (answer == 'false') {
g_scratchpad.isFormsValid = true;
} else {
var a = g_form.getBooleanValue('employment_contract_signed_by_employ');
var b = g_form.getBooleanValue('personal_details_for');
var c = g_form.getBooleanValue('tax_file_declaration');
var d = g_form.getBooleanValue('super_form_smsf_attach_compliance_letter');
if (a == false || b == false || c == false || d == false) {
g_form.addErrorMessage("Please check the checkbox for Employment contract signed by employee, Personal details, Tax details and Super Form");
return false;
}
}
g_scratchpad.isFormsValid = true;
g_form.submit(actionName);
}
}
Source: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579
Hope this helps.