url.resolveScript(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Returns an external or internal URL to a script.

Returns

string

Supported Script Types

All server scripts

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

Governance

None

Module

N/url Module

Since

2015.1

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.deploymentId

string

required

The internal ID of the deployment script.

2015.1

options.scriptId

string

required

The internal ID of the script. The ID must identify a RESTlet or a Suitelet.

2015.1

options.params

Object

optional

The object containing name/value pairs to describe the query.

2015.1

options.returnExternalUrl

boolean

optional

Indicates whether to return the external URL.

By default, the internal URL is returned (i.e., the default value is false).

2015.1

Note:

Currently, it is not possible to call a Suitelet using its internal URL from a server script. You can either use this method and set the options.returnExternalURL parameter to true to get the external URL for the Suitelet, or you can pass the cookie from the server (and concatenate “https://” appropriately). However, note that a cookie cannot be retrieved in the afterSubmit entry point, although the request parameter from which it could be retrieved is available in the beforeLoad entry point and it could be transferred to afterSubmit. This approach is not for use in backend context.

Calling a Suitelet using its internal URL is only supported in client scripts because the browser automatically adds the cookie header to the request.

Errors

Error Code

Message

Thrown If

SSS_INVALID_URL

You attempt to call a Suitelet using it’s internal URL from a server script.

SSS_INVALID_URL_CATEGORY

You used this method in a client script. This method is only supported in server scripts.

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

          //Add additional code 
...
var output = url.resolveScript({
    scriptId: 'custom_script',
    deploymentId: 'custom_script_deployment',
    returnExternalUrl: true
});
...
//Add additional code 

        

Related Topics

N/url Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices