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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- SuiteScript 2.x Sublist Values: Standard and Dynamic Mode
Use setSublistValue in standard mode; select a line, set its current value and commit it in dynamic mode. Choose the API from the record's mode.
- SuiteScript Record.setValue: Body Fields, Types and Errors
Set NetSuite body fields with Record.setValue, matching field IDs and value types and checking common API errors.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
