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 |
Returns |
void |
Supported Script Types |
Suitelets User event scripts -beforeLoad entry point For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
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.
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
required |
Encapsulates the message to be shown on the form. |
2018.2 |
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
required |
The message type. |
2016.1 |
|
|
string |
optional |
The message title. This value defaults to an empty string. |
2016.1 |
|
string |
optional |
The content of the message. This value defaults to an empty string. |
2016.1 |
|
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
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