Creating a Financial Institution Connectivity Plug-in Script File
You must implement each Financial Institution 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 Financial Institution Connectivity Plug-in that returns static data using the N/search SuiteScript module in the plug-in implementation script file:
For details on the N/search SuiteScript module, see N/search Module.
/**
* @NApiVersion 2.x
* @NScriptType fiConnectivityPlugin
* @NModuleScope SameAccount
*/
define(['N/search'],
function (search)
{
// internal function used to load configuration for this plug-in from a custom record
function loadConfiguration(configurationId)
{
var searchResults = search.create({
type: 'customrecord_sampleconfig',
filters: [{
name: 'custrecord_configurationid',
operator: 'is',
values: [configurationId]
}]
});
return searchResults.run().getRange({start: 0, end: 1});
}
function getConfigurationIFrameUrl(context)
{
var configurationId = context.pluginConfiguration.getConfigurationFieldValue({fieldName: "configuration_id"});
context.configurationIFrameUrl = "/app/site/hosting/scriptlet.nl?script=1&deploy=1&configurationId=" + configurationId;
}
function getAccounts(context)
{
var configurationId = context.pluginConfiguration.getConfigurationFieldValue({fieldName: "configuration_id"});
var configuration = loadConfiguration(configurationId)
context.addAccount({
accountMappingKey: "12345",
displayName: "Checking (XXXX11)",
accountType: "BANK",
currency: "USD",
groupName: "Bank of America",
lastUpdated: "2020-06-30T01:23:45"
});
}
function getTransactionData(context)
{
var configurationId = context.pluginConfiguration.getConfigurationFieldValue({fieldName: "configuration_id"});
var configuration = loadConfiguration(configurationId)
var accountRequests = JSON.parse(context.accountRequestsJSON);
if (accountRequests != null) {
accountRequests.forEach(function (accountRequest) {
var accountId = accountRequest.accountMappingKey;
var fromDateTime = accountRequest.dataStartTime;
var toDateTime = accountRequest.dataEndTime;
var downloadedData = "... Retrieve the account data using a web service request or a file transfer...";
context.addDataChunk({dataChunk: downloadedData});
});
}
context.returnAccountRequestsJSON({accountsJson: context.accountRequestsJSON});
}
return {
getConfigurationIFrameUrl: getConfigurationIFrameUrl,
getAccounts: getAccounts,
getTransactionData: getTransactionData
}
});
For details and breakdowns of the sample, see Financial Institution Connectivity Plug-in Interface Definition.
Guidelines for Creating a Plug-in Implementation Script File
Use the following guidelines when creating the plug-in implementation script file:
-
The plug-in script file can have any name, as long as it contains an implementation of each of the interface functions.
-
You can include utility files with helper functions when you create the plug-in implementation. See Adding the Financial Institution Connectivity Plug-in Implementation.
-
Due to limitations with how strings are handled in NetSuite, you cannot use the JavaScript case statement in the plug-in implementation script file.
-
Each interface function allows up to 1000 usage units.