Message Object Members in SuiteScript 2.1 Reference

Message object members in SuiteScript 2.1 enable message processing with methods for encoding and decryption.

·2 min read·View Oracle Docs

The Message Object Members in SuiteScript 2.1 provide a set of properties and methods crucial for handling messages effectively in your scripts. These functionalities support various operations, including processing and converting message formats, offering a powerful toolkit for server-side scripting.

Overview of Message Object Members

Properties

NameReturn Type / Value TypeSupported Script TypesDescription
Message.typebooleanServer ScriptsSpecifies how a message is processed, allowing for the appropriate method selection.

Methods

MethodReturn Type / Value TypeSupported Script TypesDescription
Message.asArmored()stringServer ScriptsConverts a message to ASCII armored format.
Message.toMessageData()pgp.MessageDataServer ScriptsConverts a message to message data if it is not encrypted.
Message.decrypt(options)pgp.MessageDataServer ScriptsDecrypts a message and verifies signatures, if required.

Syntax

The following are syntax examples for these members. Note that they are not functional examples. For a complete script implementation, you could refer to resources like the N/pgp Module Script Samples.

Example for Message Type

suitescript
// Additional code here...
const message = msgData.toMessage(); // creates Message object
log.debug(message.type);
// Additional code here...

Example for ASCII Armored Format

suitescript
// Additional code here...
const message = msgData.toMessage(); // creates Message object
log.debug(message.asArmored());
// Additional code here...

Error Handling

When working with the Message object, it's important to be aware of error codes that may arise:

  • READ_ONLY_PROPERTY: This error occurs if a write operation is attempted on a read-only property.

Related Resources

  • Visit the pgp.Message documentation for more details on the message structure and functionalities.
  • Explore the N/pgp Module for comprehensive scripting guides and examples.
  • Review the SuiteScript 2.x Modules for related operational capabilities.

Key Takeaways

  • The Message Object in SuiteScript 2.1 facilitates robust message processing.
  • Properties and methods available streamline encoding and decryption processes.
  • Understanding error handling is essential for effective scripting.

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

Frequently Asked Questions (4)

Does the Message Object apply to both client and server scripts in SuiteScript 2.1?
No, the Message Object is supported only in server scripts according to the provided article.
What happens if I try to write to a read-only property of the Message object?
Attempting to write to a read-only property of the Message object will result in a 'READ_ONLY_PROPERTY' error.
How can I convert a message into an ASCII armored format using SuiteScript 2.1?
You can use the 'Message.asArmored()' method to convert a message into an ASCII armored format in SuiteScript 2.1.
Is there a method for decrypting messages in SuiteScript 2.1's Message Object?
Yes, the 'Message.decrypt(options)' method is available to decrypt messages and verify their signatures in SuiteScript 2.1.
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 Platform

View all Platform articles →