Response Object Members in SuiteScript Machine Translation

Response Object Members provide access to translation results and errors in SuiteScript, enhancing error handling and document processing.

·2 min read·View Oracle Docs

The Response Object Members in SuiteScript's machine translation module are crucial for handling translation tasks. Understanding these members allows developers to effectively manage errors and retrieve translated documents.

What are Response Object Members?

Response Object Members are properties within the machine translation service that return errors and results from document translations. This helps developers understand any issues that arise during the translation process and manage outputs effectively.

Key Properties

Member NameReturn TypeSupported Script TypesDescription
Response.errorsmachineTranslation.Error[]Server scriptsContains any errors that occurred during translation.
Response.resultsmachineTranslation.Document[]Server scriptsContains the translated documents from the service.

Property Descriptions

  • Response.errors: This property will hold an array of machineTranslation.Error objects. Each object represents a specific error encountered during the translation process, such as unrecognized characters in the text. If no errors occurred, this array is empty.

  • Response.results: This property returns an array of translated documents. Each document is represented as a machineTranslation.Document object, allowing easy retrieval and handling of translation outputs.

Error Handling

Common Error Codes

Error CodeThrown If
READ_ONLYAttempting to set the property value.

Example Syntax

The following code demonstrates how to use the properties of the Response Object. Note that while this is not a functional example, it highlights how to handle translation results and errors.

suitescript
1// Add additional code
2...
3
4const myDocument = machineTranslation.createDocument({
5 id: 'myDoc',
6 text: 'This is a document to be translated.'
7});
8
9const translationResults = machineTranslation.translate({
10 documents: [myDocument],
11 targetLanguage: machineTranslation.Language.CZECH
12});
13
14if (translationResults.errors.length) {
15 // Handle the error message
16 const docErrorId = translationResults.errors[0].documentId;
17 const docErrorMessage = translationResults.errors[0].message;
18}
19
20...
21// Add additional code

Conclusion

Understanding the Response Object Members in SuiteScript enables developers to efficiently process translations and manage errors during the translation process. Effective error handling not only enhances the user experience but also ensures accurate translations and proper functionality of applications.

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

Frequently Asked Questions (4)

What are Response Object Members in SuiteScript?
Response Object Members are properties within the machine translation service in SuiteScript that return errors and translation results, helping developers manage translation processes effectively.
Which script types support the use of Response Object Members?
Response Object Members are supported in server scripts, facilitating error handling and document translation on the server side.
What happens if an error occurs during the translation process in SuiteScript?
If an error occurs, the 'Response.errors' property will contain an array of 'machineTranslation.Error' objects, each detailing specific issues encountered, such as unrecognized characters in the text.
Can I modify the properties of Response Object Members such as 'Response.errors'?
No, attempting to set the property value of 'Response.errors' will throw a 'READ_ONLY' error, indicating that these properties are not modifiable.
Source: Response 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 →