Message Object Members in SuiteScript 2.1 Reference
Message object members in SuiteScript 2.1 enable message processing with methods for encoding and decryption.
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
| Name | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|
Message.type | boolean | Server Scripts | Specifies how a message is processed, allowing for the appropriate method selection. |
Methods
| Method | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|
Message.asArmored() | string | Server Scripts | Converts a message to ASCII armored format. |
Message.toMessageData() | pgp.MessageData | Server Scripts | Converts a message to message data if it is not encrypted. |
Message.decrypt(options) | pgp.MessageData | Server Scripts | Decrypts 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
// Additional code here...const message = msgData.toMessage(); // creates Message objectlog.debug(message.type);// Additional code here...Example for ASCII Armored Format
// Additional code here...const message = msgData.toMessage(); // creates Message objectlog.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.
Frequently Asked Questions (4)
Does the Message Object apply to both client and server scripts in SuiteScript 2.1?
What happens if I try to write to a read-only property of the Message object?
How can I convert a message into an ASCII armored format using SuiteScript 2.1?
Is there a method for decrypting messages in SuiteScript 2.1's Message Object?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
