Creating a Custom Plug-in Alternate Implementation

Review the custom plug-in type's default implementation and any documentation provided by the solution provider.

To download a copy of the default implementation:

  1. Go to Customization > Plug-ins > Custom Plug-in Type.

  2. Click View next to the custom plug-in type you want to work with.

  3. On the Methods tab of this page, notice the names of the methods exposed in the default implementation. In your alternate implementation, you are required to use the same method names.

  4. On the Scripts tab, click download next to the default implementation file. Review this file to understand the default logic for each method.

  5. Click download next to the documentation file, if documentation has been provided by the solution provider. 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 defined in the default implementation by creating an alternate implementation. The alternate implementation overrides the custom plug-in script’s default logic. You cannot change the function signatures and 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.

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 Alternate Implementation Example

The following is a SuiteScript 2.x example of a 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 within the 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, then returns the result.

Related Topics

General Notices