Document Object Members for SuiteScript 2.1 Reference
Document Object Members provide essential properties and methods for SuiteScript 2.1, enabling MIME type retrieval and document page handling.
Starting in SuiteScript 2.1, Document Object Members are crucial for managing document data in NetSuite scripts. These members allow developers to interact with document properties and methods to extract and manipulate data effectively.
What Are Document Object Members?
The Document Object in SuiteScript provides essential properties and methods that enable developers to handle document-related operations. It includes information about the document type, its pages, and allows access to the document's textual content.
Document Properties
The Document object has the following primary properties:
| Property Name | Return Type | Description | Supported Script Types |
|---|---|---|---|
Document.mimeType | string | Contains the MIME type of the document. | Server scripts |
Document.pages | documentCapture.Page[] | Lists the pages contained in the document. | Server scripts |
Document Methods
The Document object provides essential methods to access and manipulate document data:
Document.getText()
Returns the entire text content of the document.
Example:
1// Sample code to extract document text2const extractedData = documentCapture.documentToStructure({3 file: file.load("SuiteScripts/sample_invoice.pdf"),4 documentType: documentCapture.DocumentType.INVOICE5});6 7const documentText = extractedData.getText();Supported MIME Types
The Document.mimeType property can return various MIME types, including:
- JPG -
image/jpeg - PDF -
application/pdf - PNG -
image/png - TIFF -
image/tiff
Ensure the file's extension corresponds correctly to the MIME type in your scripts.
Error Handling
When interacting with these properties, a common error might arise:
- Error Code:
READ_ONLY- Thrown If: Attempting to set the value of the
mimeTypeorpagesproperty directly will cause this error since these properties are read-only.
- Thrown If: Attempting to set the value of the
Practical Application
When using the Document object in SuiteScript, remember that the maximum number of pages returned in a typical call is five. If you require longer documents, asynchronous processing is possible, enabling handling of documents with more pages.
In conclusion, utilizing Document Object Members effectively can streamline document processing in your SuiteScripts, making data extraction and manipulation more efficient.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- Document Object Members in SuiteScript 2.1 include properties for MIME type and pages.
- Developers can use methods like
getText()to retrieve document content. - Proper error handling is crucial to manage read-only property restrictions.
- Document MIME types include
JPG,PDF,PNG, andTIFF.
Frequently Asked Questions (4)
What permissions are required to access Document Object Members in SuiteScript 2.1?
How does the Document.mimeType property handle incorrect file extensions?
Is it possible to modify the mimeType or pages properties of a Document object directly?
Can SuiteScript 2.1 Document Objects handle documents with more than five pages?
Was this article helpful?
More in General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category