Server Response Redirect Method in SuiteScript

The server response redirect method enables redirecting URLs to NetSuite resources, essential for dynamic navigation in SuiteScript.

·2 min read·View Oracle Docs

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:

ParameterTypeRequired/OptionalDescription
options.identifier`numberstring`Required
  • MEDIA_ITEM: Internal ID of a file in the File Cabinet
  • RECORD: Use the appropriate record.Type
  • RESTLET: Script ID of the RESTlet
  • SUITELET: Script ID of the Suitelet
  • TASK_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 | For SUITELET or RESTLET, this is the deployment ID; for RECORD, 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 unsupported options.type is specified.
  • SSS_MISSING_REQD_ARGUMENT: Indicates when required parameters are missing.

Syntax Example

Here is a sample of how to use this method:

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

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?
The server response redirect method is supported in server scripts within SuiteScript.
What happens if I forget to include a required parameter when using the redirect method?
If required parameters are missing, the method will throw an error with the code 'SSS_MISSING_REQD_ARGUMENT'.
Can I use the server response redirect method to redirect to a Suitelet using its script ID?
Yes, you can redirect to a Suitelet by specifying its script ID in the 'identifier' parameter and optionally its deployment ID in the 'id' parameter.
How can I pass additional URL parameters when redirecting to a NetSuite resource?
You can include additional URL parameters by using the 'parameters' property, which accepts an object of name:value pairs to include in the URL.
Source: Parameters Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →