Form.addPageInitMessage(options)

Method Description

Shows a message when users view a record or Suitelet. User event context can be used to control whether the message is shown on records in view, create, or edit mode (not applicable for Suitelets). See context.UserEventType.

This method is called during a beforeLoad user event or in a Suitelet, and the message is later displayed on the client, after the pageInit script is completed.

Returns

void

Supported Script Types

SuiteScript 2.x Suitelet Script Type and SuiteScript 2.x User Event Script Type (beforeLoad(context))

Governance

None

Module

N/ui/serverWidget Module

Since

2018.2

Parameters

The options object passed to the Form.addPageInitMessage(options) method takes a single property; either a message.Message object, or the same options object that can be passed to the message.create(options) method. The following tables list the parameters for the previously mentioned object property possibilities.

The message.Message object and the message.Type enum require loading the N/ui/message Module.

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.message

message.Message

required

Encapsulates the message to be shown on the form.

2018.2

Parameter

Type

Required / Optional

Description

Since

options.type

message.Type

required

The message type.

2016.1

options.title

string

optional

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

2016.1

options.message

string

optional

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

2016.1

options.duration

int

optional

The amount of time, in milliseconds, to show the message. The default is 0, which shows the message until Message.hide() is called.

If you specify a duration for message.create() and message.show(), the value from the message.show() method call takes precedence.

2018.2

Syntax
Important:

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

          //Add additional code 
...

// Options object as parameter 
form.addPageInitMessage({type: message.Type.INFORMATION, message: 'Hello world!', duration: 5000}); 

// Message object as parameter 
var messageObj = message.create({type: message.Type.INFORMATION, message: 'Hello world!', duration: 5000}); form.addPageInitMessage({message: messageObj}); 

// Show message when the record is in view mode
function beforeLoad(context) {
    if(context.type === 'view')
        context.form.addPageInitMessage(messageOptions);
}
...
//Add additional code 

        

General Notices