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.
Source: This article is based on Oracle's official NetSuite documentation.
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 Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category