Creating the Default Implementation for a Custom Plug-in

Important:

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. It 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.

Note:

Each function defined within the interface must be fully defined within the default implementation.

Tip:

Programming Note: Log messages written by using N/log Module functions (log.debug, log.error, log.audit, log.emergency) within a plug-in implementation are tracked on the script record that invokes the plug-in. Log level is determined by that scripts' deployment. You can see log messages by viewing the invoking script records execution log. For more information on script deployment, see SuiteScript 2.x Entry Point Script Creation and Deployment.

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

General Notices