Has anyone come up with a good way to prevent the ...
# suitescript
c
Has anyone come up with a good way to prevent the user from double-clicking a button added via form.addButton?
Ideally looking for a client-side solution like what native NetSuite has when you double-click save on a record or transaction.
n
Usually what I do is disable the button as the first action on the client script. So they don’t even have the option to click it again
if you want a message like that, you could get the status of the button on click. If its disables you can alert the user
Copy code
function customButtonFunction() {
  var button = document.getElementById('custpage_custom_button');
  button.disabled = true; // Disable the button to prevent double-clicking

  // button action stuff
  // ...

  // once button stuff is done re-enable it
  button.disabled = false;
}
But ideally, if its disabled they wouldnt even be able to click it again
c
Love that! Thanks for the suggestion - I got it working! Mostly using it for suitelet calls so this did the trick:
Copy code
objClientSideEntryPoints.windowOpen = function(stSuiteletUrl, stTargetAttribute, stButtonId)
    {
        if(stButtonId)
        {
            var objButton = document.getElementById(stButtonId);
            if(objButton)
            {
                objButton.disabled = true; // Disable the button to prevent double-clicking
            }
        }
        return window.open(stSuiteletUrl, stTargetAttribute);
    };
apartyblob 1
🎉 1