Modules

filter

 

Objects/Functions

module (N/url)

SuiteScript 2.0

Main Examples

N/url Module
Member Type: Name
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=N/url Module

// Code Example 1
/**
* @NApiVersion 2.x
*/

// This script retrieves the relative URL of a record.
require(['N/url'], function(url) {
var output = url.resolveRecord({
recordType: 'salesorder',
recordId: 6,
isEditMode: true
});
});

// Code Example 2
/**
* @NApiVersion 2.x
*/

// This script generates an absolute URL to a specific resource.
require(['N/url', 'N/record'], function(url, record) {
function resolveRecordUrl() {
var scheme = 'https://';
var host = url.resolveDomain({
hostType: url.HostType.APPLICATION
});
var relativePath = url.resolveRecord({
recordType: record.Type.SALES_ORDER,
recordId: 6,
isEditMode: true
});
var myURL = scheme + host + relativePath;
}
resolveRecordUrl();
});

// Code Example 3
/**
* @NApiVersion 2.x
*/

// This script retrieves the domain for calling a RESTlet.
require(['N/url'], function(url) {
function resolveDomainUrl() {
var sCompId = 'MSTRWLF';
var output = url.resolveDomain({
hostType: url.HostType.RESTLET,
accountId: sCompId
});
}
resolveDomainUrl();
});

// Code Example 4
/**
* @NApiVersion 2.x
*/

// This script creates a URL, sends a secure HTTPS POST request to that URL, and logs the server's response.
require(['N/url', 'N/https'], function(url, https) {
var script = 'customscript1';
var deployment = 'customdeploy1';
var parameters = '';
try {
var suiteletURL = url.resolveScript({
scriptId: script,
deploymentId: deployment
});
var response = https.post({
url: suiteletURL,
body: parameters
});
log.debug(response.body.toString());
}
catch(e) {
log.error(e.toString());
}
});

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4358552918.html