Server Response Redirect Method in SuiteScript
The server response redirect method enables redirecting URLs to NetSuite resources, essential for dynamic navigation in SuiteScript.
The server response redirect method allows developers to set a redirect URL that resolves to various NetSuite resources. This functionality is particularly useful for directing users to specific pages, such as a new sales order for a particular entity.
Method Details
- Returns:
void - Supported Script Types: Server scripts
- Governance: None
- Module: N/http Module
- Parent Object: http.ServerResponse
Parameters
The options parameter must be a JavaScript object containing the following properties:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.identifier | `number | string` | Required |
MEDIA_ITEM: Internal ID of a file in the File CabinetRECORD: Use the appropriaterecord.TypeRESTLET: Script ID of the RESTletSUITELET: Script ID of the SuiteletTASK_LINK: Valid Task ID
|
|options.type| http.RedirectType | Required | Specifies the type of resource to redirect to.
|
|options.editMode|boolean| Optional | If redirecting to a record, this indicates whether the URL should be in edit mode (true) or view mode (false, default).
|
|options.id|number | string| Optional | ForSUITELETorRESTLET, this is the deployment ID; forRECORD, the internal ID of the specific record instance.
|
|options.parameters|Object| Optional | Additional URL parameters as name:value pairs.
Errors
The method may throw the following errors:
SSS_INVALID_RECORD_TYPE: Indicates an invalid or unavailable record type.SSS_INVALID_SCRIPT_ID_1: Signifies an invalid script ID for Suitelets or RESTlets.SSS_INVALID_TASK_ID: Indicates an invalid Task ID for task link redirection.SSS_INVALID_URL_CATEGORY: Thrown when an unsupportedoptions.typeis specified.SSS_MISSING_REQD_ARGUMENT: Indicates when required parameters are missing.
Syntax Example
Here is a sample of how to use this method:
1// Example of redirecting to a sales order 2myServerResponseObj.sendRedirect({ 3 type: http.RedirectType.RECORD, 4 identifier: record.Type.SALES_ORDER, 5 parameters: {entity: 8} 6}); Additional Resources
For further details on related topics, refer to:
- http.ServerResponse
- N/http Module
- SuiteScript 2.x Modules
Understanding the server response redirect method is essential for enhancing user navigation within the SuiteScript environment and facilitating dynamic interactions with NetSuite resources.
Frequently Asked Questions (4)
Which script types support the server response redirect method in SuiteScript?
What happens if I forget to include a required parameter when using the redirect method?
Can I use the server response redirect method to redirect to a Suitelet using its script ID?
How can I pass additional URL parameters when redirecting to a NetSuite resource?
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.
