N/ui/dialog Module: Alert and Confirm Dialogs in SuiteScript
The N/ui/dialog module provides SuiteScript methods for creating alert and confirm dialogs in NetSuite client scripts.
The N/ui/dialog module is essential for developers working with SuiteScript, specifically in creating user-interactive dialogs such as alerts and confirmations. These dialogs enable developers to communicate important information or gather user responses safely and effectively.
What Methods Does the N/ui/dialog Module Offer?
The N/ui/dialog module contains several key methods:
dialog.alert(options)
The dialog.alert method creates an alert dialog that presents a message and an OK button.
- Return Type: Promise
- Supported Script Types: Client scripts
Parameters:
options.title(string, optional): Specifies the title of the alert dialog; defaults to an empty string.options.message(string, optional): Defines the content of the alert; also defaults to an empty string.
Usage Example:
Here's how to utilize the dialog.alert method:
1// Add additional code2...3function success(result) { console.log('Success with value: ' + result); }4function failure(reason) { console.log('Failure: ' + reason); }5 6dialog.alert({7 title: 'I am an Alert',8 message: 'Click OK to continue.' 9}).then(success).catch(failure);10...11// Add additional codedialog.confirm(options)
The dialog.confirm method generates a confirmation dialog that provides the user with an OK and a Cancel button.
- Return Type: Promise
- Supported Script Types: Client scripts
Parameters:
options.title(string, optional): Sets the title of the confirmation dialog; defaults to an empty string.options.message(string, optional): Outlines the content of the confirmation dialog; defaults to an empty string.
Usage Example:
Here's how you can implement the dialog.confirm method:
1// Add additional code2...3var options = {4 title: 'I am a Confirmation',5 message: 'Press OK or Cancel'6};7 8function success(result) { 9 console.log('Success with value ' + result); 10}11 12function failure(reason) { 13 console.log('Failure: ' + reason); 14}15 16dialog.confirm(options).then(success).catch(failure);17...18// Add additional codeKey Considerations
- Both methods return a Promise, allowing for further actions to be taken based on user input. You may not need to use the Promise if no follow-up action is required.
- There is no governance limit designed for these dialog methods.
Who May Find This Useful?
- Developers: Anyone developing client scripts in NetSuite needing user feedback or confirmation.
- Administrators: Those overseeing the implementation of SuiteScript and customization in the NetSuite environment.
Key Takeaways
- The N/ui/dialog module simplifies creating user alert and confirmation dialogs in SuiteScript.
- Developers can manage user interactions effectively through these dialogs.
- Dialog methods return Promises for handling user decisions asynchronously.
Frequently Asked Questions (4)
What types of scripts support the use of the N/ui/dialog module?
Do I need to handle the Promise returned by dialog.alert and dialog.confirm methods?
Can I specify titles and messages for the alert and confirm dialogs in the N/ui/dialog module?
Are there any governance limits for using the N/ui/dialog module's methods?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
