Server Response Send Redirect Method in SuiteScript

The sendRedirect method in SuiteScript allows redirection to specific NetSuite resources, enhancing navigation within scripts.

·2 min read·View Oracle Docs

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:

ParameterTypeRequired/OptionalDescription
options.identifiernumber or stringRequiredThe primary ID for the resource, based on the options.type. Different values apply for MEDIA_ITEM, RECORD, RESTLET, SUITELET, and TASK_LINK.
options.typehttp.RedirectTypeRequiredThe type of resource for redirection.
options.editModebooleanOptionalDefines whether the redirect is in edit mode (true) or view mode (false). Defaults to false.
options.idnumber or stringOptionalSecondary 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 in options.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 for options.type.
  • SSS_MISSING_REQD_ARGUMENT: A required argument is missing.

Syntax Example

Below is an example of how to use the sendRedirect method:

suitescript
1// Add any additional code here
2...
3myServerResponseObj.sendRedirect({
4 type: http.RedirectType.RECORD,
5 identifier: record.Type.SALES_ORDER,
6 parameters: {entity: 8}
7});
8...
9// Continue with more code

For further details on the http.ServerResponse and N/http module, refer to the respective documentation sections.

Related Topics

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Does the sendRedirect method in SuiteScript have any governance limits?
No, the sendRedirect method in SuiteScript does not have any governance limits associated with it.
What types of resources can I redirect users to using the sendRedirect method?
You can redirect users to resources like MEDIA_ITEM, RECORD, RESTLET, SUITELET, and TASK_LINK by specifying the appropriate options.type when using the sendRedirect method.
What are the required parameters for using the sendRedirect method in SuiteScript?
The required parameters for the sendRedirect method include options.identifier, which can be a number or string, and options.type, which specifies the type of resource for redirection using http.RedirectType.
What errors might be encountered when using the sendRedirect method incorrectly?
Errors such as SSS_INVALID_RECORD_TYPE, SSS_INVALID_SCRIPT_ID_1, SSS_INVALID_TASK_ID, SSS_INVALID_URL_CATEGORY, and SSS_MISSING_REQD_ARGUMENT can be triggered if incorrect parameters are provided to the sendRedirect method.
Source: Syntax 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 →