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
- 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