Creating a Custom Plug-in Alternate Implementation
Review the custom plug-in type's default implementation and any documentation from the solution provider.
To download a copy of the default implementation:
-
Go to Customization > Plug-ins > Custom Plug-in Type.
-
Click View next to the custom plug-in type you want to work with.
-
On the Methods tab, notice the names of the methods exposed in the default implementation. In your alternate implementation, you'll need to use the same method names.
-
On the Scripts tab, click download next to the default implementation file. Review this file to understand the default logic for each method.
-
Click download next to the documentation file if the solution provider included one. The documentation may provide additional information that explains what the methods are used for and what they return.
You can create a JavaScript file and re-implement the functions from the default implementation by creating an alternate implementation. The alternate implementation overrides the custom plug-in script’s default logic. You can't change the function signatures or return types defined in the default implementation. You can only override the logic within the function bodies. Each function that is defined in the default implementation must be fully defined in the alternative implementation.
Programming Note: Log messages written by using N/log Module functions (log.debug, log.error, log.audit, log.emergency) in a plug-in implementation are tracked on the script record that invokes the plug-in. The log level depends on that script's deployment. You can see log messages by viewing the execution log of the script that invoked the plug-in. For more information about script deployment, see SuiteScript 2.x Entry Point Script Creation and Deployment.
SuiteScript 2.x Custom Plug-in Alternate Implementation Example
The following is a SuiteScript 2.x example of an alternate implementation to the SuiteScript 2.x default implementation example shown in Creating the Default Implementation for a Custom Plug-in:
/**
* @NApiVersion 2.x
* @NScriptType plugintypeimpl
*/
define(function() {
return {
doTheMagic: function(inputObj) {
return 1234;
},
otherMethod: function() {
return 'sample';
}
}
});
This sample default implementation fully defines the doTheMagic
function. When called it in a script, this function always returns a result of 1234. This is different from the default implementation, which accepts two numbers as parameters, adds them together, and returns the result.