Document Object Members for SuiteScript 2.1 Reference
Document Object Members provide crucial properties for SuiteScript 2.1, including data content and ID retrieval for effective document handling.
Document Object Members facilitate the interaction with document-related properties within SuiteScript 2.1. This article explains the primary members, their types, and associated functionality, guiding developers to effectively utilize the Document object.
What Are Document Object Members?
The Document object members are essential properties that enable access to the content and unique identifiers of documents in SuiteScript 2.1. These members are designed for use within server scripts.
Document Object Members Overview
This section outlines the key members associated with the Document object:
| Member Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
Document.data | string | Server scripts | The content of the document. |
Document.id | string | Server scripts | The ID of the document. |
Property Details
Document.data
- Type:
string - Description: This property returns the content of a document. You specify the content using the
options.dataparameter when callingllm.createDocument(options). - Errors: Setting this property results in a
READ_ONLYerror if an attempt is made to modify it.
Document.id
- Type:
string - Description: This property returns the unique ID of a document. To specify the ID while creating a document, use the
options.idparameter inllm.createDocument(options). - Errors: Similar to
data, attempting to modify this property will throw aREAD_ONLYerror.
Syntax Example
The syntax below demonstrates how to utilize these members within a SuiteScript context:
1// The documents doc1 and doc2 are created using llm.createDocument(options)2const response = llm.generateText({3 prompt: "My test prompt",4 documents: [doc1, doc2]5});6 7// Retrieving document properties from the response8const documents = response.documents;9for (var i = 0; i < documents.length; i++) {10 var data = documents[i].data;11 var id = documents[i].id;12 // Process the document properties as needed13}Conclusion
Understanding Document Object Members is essential for effective document management within SuiteScript 2.1 scripts. By leveraging these properties, developers can streamline the handling of document data and identifiers.
Key Takeaways
- Document object enables easy access to document content and ID in SuiteScript 2.1.
- Members are read-only; attempts to modify them will trigger errors.
- Proper usage of these members enhances document management in scripts.
Frequently Asked Questions (4)
Can Document Object Members be used in client scripts or only server scripts?
What happens if I try to modify the Document.data or Document.id properties?
How do I initialize the content or ID of a Document object in SuiteScript 2.1?
Is there any way to retrieve documents' content and ID simultaneously?
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.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- 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.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category