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.

·2 min read·View Oracle Docs

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:

suitescript
1// Add additional code
2...
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 code

dialog.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:

suitescript
1// Add additional code
2...
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 code

Key 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?
The N/ui/dialog module supports client scripts in NetSuite.
Do I need to handle the Promise returned by dialog.alert and dialog.confirm methods?
Handling the Promise is optional, depending on whether you need to take further actions based on the user's input. If no follow-up action is required, you do not need to use the Promise.
Can I specify titles and messages for the alert and confirm dialogs in the N/ui/dialog module?
Yes, you can specify titles and messages for both alert and confirm dialogs using the options parameter. Titles and messages default to an empty string if not specified.
Are there any governance limits for using the N/ui/dialog module's methods?
There are no governance limits for the dialog methods in the N/ui/dialog module.
Source: N/ui/dialog Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →