Document Object Members in SuiteScript 2.1 Machine Translation

Document Object Members provide essential properties for SuiteScript 2.1's machine translation functionality, enabling document management in scripts.

·2 min read·View Oracle Docs

TL;DR Opening

Document Object Members are integral to the SuiteScript 2.1 machine translation module, allowing developers to manage documents effectively for translation tasks. This includes handling document IDs, languages, and text content that can be translated.

Overview of Document Object Members

The Document Object in SuiteScript 2.1 includes several key members, each serving a specific function in managing document data. The main members are as follows:

Member NameReturn TypeSupported Script TypesDescription
Document.idstringServer scriptsThe ID of the document.
Document.languagestringServer scriptsThe language of the document.
Document.textstringServer scriptsThe content of the document.

Member Details

Document.id

The Document.id property stores a unique identifier for the document. It's essential that all document IDs passed to the machineTranslation.translate(options) function are unique to ensure proper processing.

Document.language

This property denotes the language in which the document is written. If this property is left null, the translation service will automatically detect the document's source language. Additionally, when receiving translated documents, this property indicates the target language into which the document contents have been translated.

Document.text

Document.text holds the actual text content of the document, which is to be translated.

Error Handling

Both Document.id and Document.language properties are read-only. Attempting to set these properties will result in a READ_ONLY error code.

Example Syntax

Here is a syntactical representation of how to utilize these members. Note that this example is not functional as a complete script; it serves only to demonstrate syntax usage:

suitescript
1const myDocument = machineTranslation.createDocument({
2 id: 'myDoc',
3 text: 'This is a document to be translated.'
4});
5
6const translationResults = machineTranslation.translate({
7 documents: [myDocument],
8 targetLanguage: machineTranslation.Language.CZECH
9});
10
11const docId = translationResults.results[0].id;

Who This Affects

  • Developers: They can implement document translation features using the properties detailed above.
  • Administrators: Administrators may need to configure permissions and settings associated with document management in machine translation.

Key Takeaways

  • Document members in SuiteScript 2.1 facilitate efficient document handling for machine translation.
  • Each document requires a unique ID for the translation process.
  • Document.language and Document.text are pivotal for successful translation workflow.

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

Frequently Asked Questions (4)

Which script types support the use of Document Object Members in SuiteScript 2.1?
Document Object Members are supported in server scripts.
Can I change the value of Document.id or Document.language in SuiteScript 2.1?
No, both Document.id and Document.language are read-only properties. Attempting to set them will trigger a READ_ONLY error.
What happens if the Document.language property is set to null?
If Document.language is null, the translation service will automatically detect the document's source language for translation.
How should Document.id be handled when managing multiple documents for translation?
Each Document.id must be unique to ensure proper processing when using the machineTranslation.translate function.
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 Integration

View all Integration articles →