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.

·2 min read·View Oracle Docs

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 NameReturn TypeSupported Script TypesDescription
Document.datastringServer scriptsThe content of the document.
Document.idstringServer scriptsThe 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.data parameter when calling llm.createDocument(options).
  • Errors: Setting this property results in a READ_ONLY error 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.id parameter in llm.createDocument(options).
  • Errors: Similar to data, attempting to modify this property will throw a READ_ONLY error.

Syntax Example

The syntax below demonstrates how to utilize these members within a SuiteScript context:

suitescript
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 response
8const 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 needed
13}

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.

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

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?
Document Object Members are designed specifically for use within server scripts in SuiteScript 2.1.
What happens if I try to modify the Document.data or Document.id properties?
Both Document.data and Document.id are read-only properties. Attempting to modify them will result in a 'READ_ONLY' error.
How do I initialize the content or ID of a Document object in SuiteScript 2.1?
You can specify the content and ID of a Document object using the 'options.data' and 'options.id' parameters, respectively, when calling 'llm.createDocument(options)'.
Is there any way to retrieve documents' content and ID simultaneously?
Yes, once you have the response from 'llm.generateText', you can loop through 'response.documents' array to access each document's 'data' and 'id' properties.
Source: Document 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 →