Restrict the Multiple Click of a Button

We need to restrict the multiple clicks of a button in a suitelet page or a record. Because of the button is a button action, then multiple time submit action will trigger and causes the error. The proposed solution for restricting the multiple button click in a page is we should disable the button after the user clicks the button so that the user won’t click the button multiple times. The button will be back to normal once the user refreshes the page. The button is disabled by the jquery function. We need to mention the button id in the jquery function. The button id can be got by inspecting the button in the browser

  function attachPolicy() {
            try {
                currentRecID = currentRecord.get().id;
                var output = url.resolveScript({
                    scriptId: 'customscript_jj_sl_aq_224_attach_policy',
                    deploymentId: 'customdeploy_jj_sl_aq_224_attach_policy',
                    returnExternalUrl: false,
                }) + '&recId=' + currentRecID;
                window.open(output);
                //disable the button and decreases the opacity of the button so the user can identify the button is disabled
                if (jQuery('#tdbody_custpage_attach_policy').length == 1) {
                    jQuery('#tdbody_custpage_attach_policy').css('pointer-events', 'none');
                    jQuery('#tdbody_custpage_attach_policy').css('opacity', '0.6');
                }
            } catch (err) {
                console.log("ERROR", JSON.stringify(err));
            }
        }

Leave a comment

Your email address will not be published. Required fields are marked *