Disable a button with a client script
# ask-stanley-ai
p
Disable a button with a client script
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To disable a button with a client script in NetSuite, you can use JavaScript to manipulate the DOM. However, it's important to note that this method is not technically supported by NetSuite. Here is an example of how you can disable a button:
Copy code
javascript
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;
}
In this example, the button is disabled as the first action when the function is called. This prevents the user from double-clicking the button. Once the actions associated with the button are completed, the button is re-enabled. Another method is to change the CSS class of the button to 'pgBntGDis', which is the class NetSuite uses to gray out and disable buttons. However, this method may not work in all cases as it depends on the specific implementation of the button. Please note that these methods are workarounds and may not work in all cases or for all types of buttons. Always test thoroughly to ensure the desired behavior is achieved.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847904205
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844600379
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832457483
Please provide your feedback on this answer.