Creating the Bank Connectivity Plug-in Script File

You must implement each Bank Connectivity Plug-in interface function in a JavaScript file (with a .js extension) to define the behavior of the plug-in implementation. You can use the SuiteCloud IDE or another JavaScript IDE or text editor to create the plug-in script file.

The following sample implements a basic sFTP connection using the 'N/sftp' SuiteScript module in the plug-in implementation script file:

Note:

The 'N/sftp' SuiteScript module supports regular expressions as of 2019.2. For details, see N/sftp Module.

              /**
 * @NApiVersion 2.0
 * @NScriptType bankConnectivityPlugin
 */
define(['N/sftp', 'N/file'],
    function(sftp, file) {
        return {
            getRequiredConfigurationFields: function (context) {
                //Connection details
                context.output.addConfigurationField({type:"TEXT", label:"URL", dataName:"url"});
                context.output.addConfigurationField({type:"TEXT", label:"User name", dataName:"username"});
                context.output.addConfigurationField({type:"PASSWORD", label:"Password", dataName:"password"});
                context.output.addConfigurationField({type:"TEXT", label:"Host Key", dataName:"hostKey"});
                context.output.addConfigurationField({type:"TEXT", label:"Host Key Type", dataName:"hostKeyType"});
                context.output.addConfigurationField({type:"TEXT", label:"Port", dataName:"port"});
 
                //File download details
                context.output.addConfigurationField({type:"TEXT", label:"Download Filename", dataName:"filename"});
                context.output.addConfigurationField({type:"TEXT", label:"Download Directory", dataName:"directory"});
                context.output.addConfigurationField({type:"TEXT", label:"Download Timeout", dataName:"timeout"});
                context.output.addConfigurationField({type:"TEXT", label:"Bank statement format", dataName:"format"});
            },
            downloadPreviousDayBankStatementFile: function (context) {
                var config = context.input.pluginConfiguration;
                var connection = sftp.createConnection({
                    url: config.getConfigurationFieldValue({fieldName:"url"}),
                    passwordGuid: config.getConfigurationFieldValue({fieldName:"password"}),
                    hostKey: config.getConfigurationFieldValue({fieldName:"hostKey"}),
                    hostKeyType: config.getConfigurationFieldValue({fieldName:"hostKeyType"}),
                    username: config.getConfigurationFieldValue({fieldName:"username"}),
                    port: parseInt(config.getConfigurationFieldValue({fieldName:"port"}))
                });
                var downloadedFile = connection.download({
                    filename: config.getConfigurationFieldValue({fieldName:"filename"}),
                    directory: config.getConfigurationFieldValue({fieldName:"directory"}),
                    timeout: config.getConfigurationFieldValue({fieldName:"timeout"})
                });
                context.output.saveBankStatementFile({file: downloadedFile, bankStatementFormat: config.getConfigurationFieldValue({fieldName:"format"})});
            },
        }
    }
); 

        

For details and breakdowns of the sample, see Bank Connectivity Plug-in Interface Definition.

The following table describes the interface functions:

Function

Description

getRequiredConfigurationFields (context)

Define the configuration requirements for your bank connectivity implementation. For example, a specific bank may require a secret user name and password to connect.

This function is called when you open the plug-in configuration page. (used to define the fields you see on that page)

downloadPreviousDayBankStatementFile (context)

Request a statement from the bank. When you request a statement from NetSuite, the plug-in calls the function which makes the download request to the bank. The bank sends the statement back to the plug-in, then the plug-in formats and sends the statement to NetSuite. Continue with other stages of the Cash Management workflow, like transaction matching.

Rules and Guidelines for Creating a Plug-in Implementation Script File

Use the following rules and guidelines when creating the plug-in implementation script file:

Related Topics

Developing a Bank Connectivity Plug-in
Enabling Features for a Bank Connectivity Plug-in
Obtaining the Host Key

General Notices