I have a custom button that opens a suitelet in a ...
# ask-stanley-ai
s
I have a custom button that opens a suitelet in a new tab, where the user inputs and submits information. How do I get the Suitelet to open in dialog or modal box on the original page, instead of a new tab?
c
AI generated answer (using internal Slack threads):
To open a Suitelet in a dialog or modal box on the original page, instead of a new tab, you can use the
N/ui/dialog
module in SuiteScript 2.0. This module provides methods to create and control dialog boxes. Here is a sample code snippet that demonstrates how to create a dialog box:
Copy code
javascript
require(['N/ui/dialog'], function(dialog) {
    var myDialog = dialog.create({
        title: 'My Dialog',
        message: 'This is a simple dialog box.',
        buttons: [dialog.Button.OK]
    });
    myDialog.show();
});
In your case, you would need to modify the Suitelet to return the HTML content you want to display in the dialog box. Then, in the client script of the original page, you would call the Suitelet, retrieve the HTML content, and display it in the dialog box. Please note that the dialog box is modal, meaning that it prevents the user from interacting with the rest of the UI until the dialog box is closed. Also, the dialog box is not a full-fledged browser window, so it does not support all HTML features. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85816741
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854592204
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852431
Please provide your feedback on this answer.