ServerResponse.sendRedirect(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Sets the redirect URL by resolving to a NetSuite resource.

For example, you could use this method to redirect to a new sales order page for a particular entity.

Returns

void

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/http Module

Parent Object

http.ServerResponse

Sibling Object Members

ServerResponse Object Members

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.identifier

number | string

required

The primary ID for this resource. The value you use varies depending on the value of options.type, as follows:

  • MEDIA_ITEM — Use the internal ID of a file stored in the NetSuite File Cabinet.

  • RECORD — Use record.Type to identify the appropriate record type.

  • RESTLET — Use the script ID from the script record of the appropriate RESTlet.

  • SUITELET — Use the script ID from the script record of the appropriate Suitelet.

  • TASK_LINK — Use the appropriate Task ID. Supported IDs are listed in Task IDs.

2015.2

options.type

http.RedirectType

required

The type of resource redirected to.

2015.2

options.editMode

boolean

optional

Applicable when redirecting to a record resource.

Specifies whether to return a URL for a record in edit mode or view mode.

If set to true , returns the record in edit mode. If set to false , returns the record in view mode.

The default value is false.

2015.2

options.id

number | string

optional

The secondary ID for this resource. If the options.type parameter is set to SUITELET or RESTLET, use the deployment ID. If the options.type parameter is set to RECORD, you can use the internal ID of a specific record instance.

2015.2

options.parameters

Object

optional

Additional URL parameters as name:value pairs.

2015.2

Errors

Error Code

Message

Thrown If

SSS_INVALID_RECORD_TYPE

Type argument {type} is not a valid record or is not available in your account. Please see the documentation for a list of supported record types.

The redirect type is set to record, and an invalid record type is input for options.identifier.

SSS_INVALID_SCRIPT_ID_1

You have provided an invalid script id or internal id: {id}

The type is set to Suitelet or RESTlet, and an invalid script ID or invalid deployment ID is input for options.identifier or options.id.

SSS_INVALID_TASK_ID

The task ID: {id} is not valid. Please refer to the documentation for a list of supported task IDs.

The type is set to task link, and an invalid task ID is input for options.identifier.

SSS_INVALID_URL_CATEGORY

The options.type: {type} is not valid. Please use http.RedirectType for supported types.

The script uses an unrecognizable string value for the options.type parameter. To avoid this error, use http.RedirectType.

SSS_MISSING_REQD_ARGUMENT

Missing a required argument: {param name}

The options.identifier or options.type parameter is not specified. Note that this error is thrown if an enum is misspelled within a script. For example, you see this error if you use http.RedirectType.TASKLINK instead of http.RedirectType.TASK_LINK in the options.type field.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.

          // Add additional code 
...
myServerResponseObj.sendRedirect({
    type: http.RedirectType.RECORD,
    identifier: record.Type.SALES_ORDER,
    parameters: {entity: 8}
});
... 
// Add additional code 

        

Related Topics

http.ServerResponse
N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices