ServerResponse.sendRedirect(options)

Method Description

Creates a redirect URL that resolves 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/https Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Important:

All parameters must be prefixed with custparam.

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

string

required

The type of resource to which the script redirects. Use https.RedirectType to set a value for this parameter.

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

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

INVALID_ID

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

The options.type parameter is set to RESTLET or SUITELET, and the script uses an invalid ID for options.identifier or options.id.

INVALID_RCRD_TYPE

The record type {type} is invalid.

The options.type parameter is set to RECORD, and the script uses an unrecognizable string value for options.identifier. To avoid this error, use record.Type to identify the appropriate record type.

INVALID_TASK_ID

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

The options.type parameter is set to TASK_LINK, and the script uses an invalid task ID for options.identifier. For a list of valid IDs, see Task IDs.

SSS_INVALID_URL_CATEGORY

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

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

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/https Module Script Samples.

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

        

Related Topics

General Notices