Creating Custom Plug-ins
To create custom plug-ins to use with NSPB Sync, you can do the following:
-
Customize the NSPB Sync post-processing plug-ins. See Using NSPB Sync Post-Processing Plug-ins.
-
Use plug-ins implemented in NetSuite to create and format your custom plug-ins.
-
Create additional plug-ins to process files generated in your Planning and Budgeting.
You can then use the plug-ins to process any data generated by a job and downloaded from Inbox/Outbox Explorer or File Browser's inbox to NetSuite. For information, see Using Custom Plug-ins with NSPB Sync.
You can use post-processing plug-ins with the following job types:
-
Batch jobs
-
Business rules
-
Data load rules
Example of a Plug-in for Data Load Rule Export
The plug-ins you use for data load rule export should have the following format:
/**
* @NApiVersion 2.1
* @NScriptType plugintypeimpl
*/
define([], function() {
/**
* Return configuration parameters of this plugin that are required by calling code
* E.g.: path to csv file in NSPB to be downloaded
* @returns {Object} options - configuration parameters
*/
function getConfiguration() {
log.debug('running plugin getConfiguration');
let options = {
jobParams: {
dataFilePath: 'nspbcsBudgetDm.csv', // path to csv file in NSPB to be downloaded
dataFileHeaderLines: 1, // optional, number of header lines in data file
dataChunkSize: 300, // optional, maximum number of records for each chunk of data to pass to processData per function call
dataChunkGrouping: { // optional, enforce grouping records of the same value into the same data chunk
enabled: true,
groupFieldIndexes: [ // indexes of fields to use to determine data of the same group
0, // account
1, // class
2, // subsidiary
3, // location
4, // department
5, // tracker
6, // item
7, // relationship
8, // version
9, // scenario
10, // currency
11 // year
]
}
};
return options;
}
/**
* @Description Process any data generated by Data Exchange Module (Data Load Job)
* @param {Object} options - the function parameters
* @param {String} options.jobData - Data Load Job data retrieved from NSPB
*/
function processData(options) {
log.debug('processData', 'Running import budget data plugin processData with job data: ' + options.jobData);
let budgetData = options.jobData;
}
return {
getConfiguration: getConfiguration,
processData: processData
};
});
Example of a Plug-in for Business Rule Export
The plug-ins you use for business rule export should have the following format:
/**
* @NApiVersion 2.1
* @NScriptType plugintypeimpl
*/
define([], function() {
/**
* Return configuration parameters of this plugin that are required by calling code
* E.g.: path to csv file in NSPB to be downloaded
* @returns {Object} options - configuration parameters
*/
function getConfiguration() {
log.debug('running plugin getConfiguration');
var options = {
jobParams: {
dataFilePath: 'nspbcsBudgetBr.csv', // path to csv file in NSPB to be downloaded
dataFileHeaderLines: 2, // optional, number of header lines in data file
dataChunkSize: 300 // optional, maximum number of records for each chunk of data to pass to processData per function call
}
};
return options;
}
/**
* @Description Process any data generated by a Business Rule
* @param {Object} options - the function parameters
* @param {String} options.jobData - Business Rule job data retrieved from NSPB
*/
function processData(options) {
log.debug('processData', 'Running import budget data plugin processData with job data: ' + options.jobData);
var budgetData = options.jobData;
}
return {
getConfiguration: getConfiguration,
processData: processData
};
});
Plug-in Script Configuration Details
Read the following details about configuration of plug-in scripts:
-
The name of the export file that is downloaded from Inbox/Outbox Explorer or File Browser's inbox must match exactly the file name defined in the plug-in you are using.
-
The
getConfiguration
function identifies the export file that needs to be imported from your Planning and Budgeting. NSPB Sync downloads the file to NetSuite and executes theprocessData
function of the plug-in. -
To process large volumes of data, you can use the following optional parameters with the
getConfiguration
function:-
dataChunkSize
-
dataFileHeaderLines
-
dataChunkGrouping
The
dataChunkSize
parameter lets you break a large export file into smaller chunks to improve performance. The optimal value is 300.The
dataFileHeaderLines
parameter configures the number of lines to include in the header of the export file. You need to enter 1 for data load rule export or 2 for business rule export.The
dataChunkGrouping
parameter groups records with the same column index into the same chunk. You can use this parameter only in script files for data load rule export.Note:The
dataChunkSize
,dataFileHeaderLines
anddataChunkGrouping
parameters are included in the NSPB Sync post-processing plug-ins. To use these parameters in your custom plug-ins, you need to include and configure the parameters manually in your plug-ins. -
-
The year format that you should use in your plug-in scripts is FY<yy>. For example, FY23 or FY24.