N/ui/dialog Module: Creating Alert and Confirm Dialogs
The N/ui/dialog module provides SuiteScript methods for creating alert and confirm dialogs, enhancing user interactions in NetSuite.
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category