url.resolveScript(options)
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 |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.1 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string | number |
required |
The script ID (string) or internal ID (number) of the deployment script. |
2015.1 |
|
string | number |
required |
The script ID (string) or internal ID (number) of the script. The ID must identify a RESTlet or a Suitelet. |
2015.1 |
|
Object |
optional |
The object containing name/value pairs to describe the query. |
2015.1 |
|
boolean |
optional |
Indicates whether to return the external URL. By default, the internal URL is returned (that is, the default value is false). |
2015.1 |
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 |
---|---|---|
|
|
You attempt to call a Suitelet using its internal URL from a server script. |
Syntax
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