ServerResponse Write Function for SuiteScript Development
The ServerResponse write method in SuiteScript allows you to send string data in response to HTTP requests, ensuring efficient server communication.
The ServerResponse write method lets developers send string outputs (text, XML, HTML) to the client in SuiteScript applications. This method is essential for delivering data-driven responses in server-side scripts.
Method Description
The write method writes information to the response but is limited to string values. To include files in the response, consider using the writeFile method instead.
Returns
void: This method does not return a value.
Supported Script Types
- Server scripts
Governance
- There are no governance limits for using this method.
Module
- This method is part of the N/http Module.
Parent Object
- The parent object for this method is
http.ServerResponse.
Parameters
The options parameter is a JavaScript object with the following structure:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.output | string | required | The string you want to write to the response. |
Errors
When using this method, be mindful of the following potential errors:
| Error Code | Message | Thrown If |
|---|---|---|
SSS_MISSING_REQD_ARGUMENT | Missing a required argument: {param name} | The options.output parameter is not specified. |
WRONG_PARAMETER_TYPE | {param name} | The options.output parameter is not a string. |
Syntax
The following code sample illustrates the syntax for the write method:
1// Add additional code 2...3serverResponse.write({4 output: 'Hello World'5});6...7// Add additional codeRelated Topics
- http.ServerResponse
- N/http Module
- SuiteScript 2.x Modules
- SuiteScript 2.x
Key Takeaways
- The
writemethod is used to output string data directly to the HTTP response. - Proper error handling ensures that required string outputs are checked before execution.
- Understanding the distinctions between
writeandwriteFileaids in managing responses correctly.
Frequently Asked Questions (4)
Which SuiteScript types support using the ServerResponse write method?
Do I need to be concerned about governance limits when using the ServerResponse write method?
Is there a special module that the ServerResponse write method is part of?
What errors should I watch out for when using the ServerResponse write method?
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.
