dialog.create(options)

Method Description

Creates a dialog with specified buttons.

Returns

Promise Object. To run a callback function when a button is pressed, pass a function to the then portion of the Promise object. The value of the button pressed is passed to the callback.

Supported Script Types

Client scripts

For more information, see SuiteScript 2.x Client Script Type.

Governance

None

Module

N/ui/dialog Module

Since

2016.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.buttons

string[]

optional

A list of buttons to include in the dialog. Each item in the button list must be a Javascript Object that contains a label and a value property.

By default, a single button with the label OK and the value true is used.

2016.1

options.title

string

optional

The dialog title. This value defaults to an empty string.

2016.1

options.message

string

optional

The content of the dialog. This value defaults to an empty string.

2016.1

Errors

Error Code

Error Message

Thrown If

WRONG_PARAMETER_TYPE

Wrong parameter type: {1} is expected as {2}.

The options.buttons parameter is specified and is not an array.

BUTTONS_MUST_INCLUDE_BOTH_A_LABEL_AND_VALUE

Buttons must include both a label and value.

The options.buttons parameter is specified and one or more items do not have a label, a value, or both.

Syntax

Important:

The following code snippet shows the syntax for this member. It is not a functional example. For a complete script example, see N/ui/dialog Module Script Samples.

                     //Add additional code 
            ...
        var options = {
            title: 'I am a Dialog with 3 custom buttons',
            message: 'Click a button to continue.',
            buttons: [
                { label: '1', value: 1 },
                { label: '2', value: 2 },
                { label: '3', value: 3 }]
        };

        function success(result) { console.log('Success with value: ' + result) }
        function failure(reason) { console.log('Failure: ' + reason) }

        dialog.create(options).then(success).catch(failure);
        ...
            //Add additional code 

          

The following screenshot shows an example of a Custom dialog with three buttons:

A dialog with an I am a Dialog with 3 custom buttons title and three buttons.

If no buttons are specified, a single value with the label OK is used:

                     //Add additional code 
            ...
         dialog.create({
               title: 'I am a Dialog with the default button',
               message: 'Click a button to continue.'
          });    
        ...
            //Add additional code 

          
A dialog with I am a Dialog with the default button title and an OK button.

Related Topics

General Notices