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.
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 Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
Response.errors | machineTranslation.Error[] | Server scripts | Contains any errors that occurred during translation. |
Response.results | machineTranslation.Document[] | Server scripts | Contains the translated documents from the service. |
Property Descriptions
-
Response.errors: This property will hold an array of
machineTranslation.Errorobjects. 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.Documentobject, allowing easy retrieval and handling of translation outputs.
Error Handling
Common Error Codes
| Error Code | Thrown If |
|---|---|
READ_ONLY | Attempting 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.
1// Add additional code2...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.CZECH12});13 14if (translationResults.errors.length) {15 // Handle the error message16 const docErrorId = translationResults.errors[0].documentId;17 const docErrorMessage = translationResults.errors[0].message;18}19 20...21// Add additional codeConclusion
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.
Frequently Asked Questions (4)
What are Response Object Members in SuiteScript?
Which script types support the use of Response Object Members?
What happens if an error occurs during the translation process in SuiteScript?
Can I modify the properties of Response Object Members such as 'Response.errors'?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
