Server Response Send Redirect Method in SuiteScript
The sendRedirect method in SuiteScript allows redirection to specific NetSuite resources, enhancing navigation within scripts.
The sendRedirect method in SuiteScript enables developers to set a redirect URL that points to various NetSuite resources, facilitating a smoother navigation experience within applications. This method is particularly useful for redirecting users to specific pages, such as new sales orders for particular entities.
Method Description
The sendRedirect method resolves to a NetSuite resource based on provided parameters. Below is a summary of the functionality:
- Returns: The method returns
void. - Supported Script Types: Applicable in server scripts.
- Governance: There is no governance limit associated with this method.
Module: N/http Module
Parent Object: http.ServerResponse
Since: 2015.2
Parameters
When using the sendRedirect method, you can supply an options parameter, which is a JavaScript object, including the following:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.identifier | number or string | Required | The primary ID for the resource, based on the options.type. Different values apply for MEDIA_ITEM, RECORD, RESTLET, SUITELET, and TASK_LINK. |
options.type | http.RedirectType | Required | The type of resource for redirection. |
options.editMode | boolean | Optional | Defines whether the redirect is in edit mode (true) or view mode (false). Defaults to false. |
options.id | number or string | Optional | Secondary ID for this resource. Used for deployment ID with SUITELET or RESTLET types. |
|| options.parameters | Object | Optional | Additional URL parameters as name:value pairs to be included in the redirect. |
Errors
Several error codes can be triggered when using sendRedirect:
SSS_INVALID_RECORD_TYPE: An invalid record type is provided inoptions.identifier.SSS_INVALID_SCRIPT_ID_1: An invalid script ID is used for a Suitelet or RESTlet.SSS_INVALID_TASK_ID: A provided task ID is not valid.SSS_INVALID_URL_CATEGORY: An unrecognized string value foroptions.type.SSS_MISSING_REQD_ARGUMENT: A required argument is missing.
Syntax Example
Below is an example of how to use the sendRedirect method:
1// Add any additional code here2...3myServerResponseObj.sendRedirect({4 type: http.RedirectType.RECORD,5 identifier: record.Type.SALES_ORDER,6 parameters: {entity: 8}7});8...9// Continue with more codeFor further details on the http.ServerResponse and N/http module, refer to the respective documentation sections.
Related Topics
- http.ServerResponse
- N/http Module
- SuiteScript 2.x Modules
Frequently Asked Questions (4)
Does the sendRedirect method in SuiteScript have any governance limits?
What types of resources can I redirect users to using the sendRedirect method?
What are the required parameters for using the sendRedirect method in SuiteScript?
What errors might be encountered when using the sendRedirect method incorrectly?
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.
