SuiteScript Response Object Members for Machine Translation
Response Object Members provide access to SuiteScript translation results and errors for improved error handling.
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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category