Message Object Members

Discover the Message object methods in SuiteScript, enabling effective message display and management in client scripts.

·2 min read·View Oracle Docs

The Message object in SuiteScript provides developers with methods to manage notifications displayed to users. It allows you to show or hide messages dynamically, enhancing user interaction with applications. Understanding how to utilize these methods is essential for effective client-side scripting.

What Are the Message Object Members?

The Message object includes members that define how messages are shown and hidden within SuiteScript client scripts. Here’s a breakdown of its primary methods:

Member NameReturn TypeSupported Script TypesDescription
Message.hide()voidClient scriptsHides the currently displayed message.
Message.show(options)voidClient scriptsDisplays a message with optional parameters.

How Does Message.show(options) Work?

The Message.show(options) method displays a message in the UI. Here is what you need to know:

  • Parameters: The options parameter is a JavaScript object that can include:
    • duration: (optional) Duration to display the message in milliseconds. If set to 0, the message remains visible until it is manually hidden.
  • Error Handling: If the duration provided is not a number or string that can be parsed, an error with the code WRONG_PARAMETER_TYPE is thrown.

Code Example for Showing a Message

Here's a simple code snippet that showcases how it works:

suitescript
1// Example script to create and show a message
2var myMsg = message.create({
3 title: "My Title 2",
4 message: "My Message 2",
5 type: message.Type.INFORMATION
6});
7myMsg.show({ duration: 1500 }); // Shows the message for 1500ms

How Does Message.hide() Work?

The Message.hide() method hides the currently displayed message. It doesn't return any value and is essential for managing the user interface dynamically, especially when using timed displays or responding to user actions.

Code Example for Hiding a Message

Below is an example demonstrating how to hide a message:

suitescript
// Example script to hide a message after a delay
setTimeout(function() {
myMsg.hide(); // Hides the message after 15 seconds
}, 15000);

Summary of Key Features

  • The Message object enhances user experience by allowing notifications via messages.
  • Both methods show() and hide() are easy to implement and critical for effective user interface management in SuiteScript.

Who This Affects

  • Administrators: Responsible for implementing client scripts and managing UI messages.
  • Developers: Utilize the Message object methods for creating dynamic applications.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The Message object enables show/hide functionality for messages in SuiteScript.
  • Customize message duration to control user notifications effectively.
  • Error handling is essential when using parameters in message methods.

Frequently Asked Questions (4)

Do I need special permissions to use the Message object in client scripts?
No special permissions are required to use the Message object in client scripts. It is available to developers and administrators working on SuiteScript.
Can the 'Message.show(options)' method display a message indefinitely?
Yes, by setting the 'duration' parameter to 0, the message is displayed indefinitely until it is manually hidden.
What happens if I provide a non-numeric value for the duration parameter in 'Message.show(options)'?
Providing a non-numeric value for the duration parameter will result in an error with the code 'WRONG_PARAMETER_TYPE'.
Is there a method to check if a message is currently displayed using the Message object?
The article does not mention a method to check if a message is currently displayed. The functionality is primarily focused on showing and hiding messages.
Source: Message Object 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 General

View all General articles →