Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Unable to submit form after one click on submit button

ash_1998
Tera Contributor

Subject: Unable to submit form after one click on submit button

Description: The user has to click on Submit Button 3 times after updating the details to submit the form. If the Submit button is clicked once or twice, the form doesn't get submitted.

 

We have found its happening due to 2 on submit catalog client script.. Could you please here me here to find out what's going wrong exactly in script

 

Script 1 - If the user is from new zeland showing  errors message to check the required checkboxes

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();
        }
    }
}
 
 
Script 2 - If the user is from Australia showing  errors message to check the required checkboxes
 
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();
        }
    }
}
 
 
This two script causing the issue , if we deactivate the both script form getting submitted in one Click only..
 
Thanks.
0 REPLIES 0