NetSuite-side require() the node.js
You can use require()
the node.js freely on yours JavaScripts.
- node.js 4+
sudo npm install nsify -g
Generate your SuiteScripts:
- input: restlet-with-require.js
- output: suite-script-nsify-restlet.js
nsify ./test/_files/RE-process-restlet.js >> suite-script-process-restlet.js
var nsify = require('nsify'),
filePath = './test/_files/custom/schedule-simple.js',
nsObj = nsify.annotation(filePath);
console.log(nsObj); // see output
- input: schedule-simple.js
- output:
{
"id": "sp-schedule",
"type": "schedule",
"alias": "MySchedule",
"function": "MySchedule.process",
"libs": [
"my-lib.js"
],
"params": {
"param1": {"name": "Param 1", "type": "INTEGER"}
}
}
Compatibility with nsmockup
var nsify = require('nsify'),
nsmockup = require('nsmockup');
nsmockup.init(function() {
let filePath = './test/_files/custom/schedule-simple.js',
script = nsify.annotation(filePath, 'nsmockup');
console.log(script); // see output
nsmockup.createSuiteScript(script.type, script, function($ctx) {
let alias = script.alias;
if ($ctx[alias]) {
console.log(':D works!!');
}
});
});