Creating a Custom Plug-in Default Implementation
To create your own custom plug-ins and implementation scripts, you need some JavaScript coding experience and an understanding of SuiteScript. You should write new custom plug-in scripts in SuiteScript 2.0 or SuiteScript 2.1. To get started with SuiteScript, see SuiteScript 2.x API Reference and SuiteScript 2.1.
An implementation fully defines an interface’s functions. In other words, an implementation contains the logic executed by an interface’s functions. When developing a plug-in, you must define a default implementation to define the custom plug-in script’s default logic. A default implementation is written as an independent JavaScript file.
Each function defined within the interface must be fully defined within the default implementation.
SuiteScript 2.x Custom Plug-in Default Implementation Example
The following is a SuiteScript 2.x example of a default implementation:
/**
* @NApiVersion 2.x
* @NScriptType plugintypeimpl
*/
define(function() {
return {
doTheMagic: function(inputObj) {
var operand1 = parseFloat(inputObj.operand1);
var operand2 = parseFloat(inputObj.operand2);
if (!isNaN(operand1) && !isNaN(operand2)) {
return operand1 + operand2;
}
},
otherMethod: function() {
return 'sample';
}
}
});
This sample default implementation fully defines the doTheMagic
function. When called within the custom plug-in script, this function accepts two numbers, operand1
and operand2
, and adds them together to return a result.
Related Topics
- Custom Plug-in Overview
- Custom Plug-in Development
- Creating a Custom Plug-in Interface
- Adding the Default Implementation to NetSuite
- Instantiating a Custom Plug-in Script in SuiteScript 2.x
- Instantiating a Custom Plug-in Script in SuiteScript 1.0
- Adding a Script that Instantiates a Custom Plug-in to NetSuite
- Bundling a Custom Plug-in
- Custom Plug-in Creation