๐น What are Custom GL Plugins?
Custom GL Plugins in NetSuite allow developers to manipulate how transactions post to the General Ledger (GL).
By default, NetSuite posts accounting entries based on its internal logic. But sometimes, businesses need custom rules โ for example:
- Redirecting revenue accounts based on customer type.
- Splitting costs into multiple GL accounts dynamically.
- Recording additional lines for reporting or compliance.
This is where Custom GL Lines Plug-ins (GL Impact plug-ins) come in.
๐น Why Use Custom GL Plugins?
- Override standard GL impact of transactions.
- Automate revenue allocation, tax handling, or intercompany adjustments.
- Improve reporting accuracy.
- Reduce manual journal adjustments.
๐น Key Points to Remember
- The plug-in type is Custom GL Lines (
customscript_gl_plugin
). - The entry point methods include:
generateLines(context)
โ Define new GL lines.modifyLines(context)
โ Change existing GL lines.reverseLines(context)
โ Reverse lines in specific cases.
๐น Example: Redirecting Revenue Based on Subsidiary
Below is a simple example of a Custom GL Lines Plug-in.
/**
* @NApiVersion 2.x
* @NScriptType CustomGLPlugin
* @NModuleScope Public
*
* Example: Redirect revenue accounts based on subsidiary
*/
define(['N/log'], function (log) {
function CustomGLPlugin() { }
/**
* Generate additional GL lines
* @param {Object} context - Contains transaction and standard GL lines
*/
CustomGLPlugin.prototype.generateLines = function (context) {
try {
var transaction = context.transactionRecord;
var subsidiary = transaction.getValue({ fieldId: 'subsidiary' });
// Loop through standard GL lines
context.standardLines.iterator().each(function (line) {
var accountId = line.getAccountId();
// Example: Redirect revenue to custom account if subsidiary = 2
if (subsidiary == 2 && line.creditAmount > 0) {
var customLine = context.lines.addNewLine();
customLine.setAccountId(1234); // custom revenue account
customLine.setCreditAmount(line.creditAmount);
customLine.setMemo("Redirected Revenue for Subsidiary 2");
// Neutralize original line
line.setCreditAmount(0);
}
return true;
});
} catch (e) {
log.error('Error in generateLines', e);
}
};
return CustomGLPlugin;
});
๐ Explanation of the Code
context.transactionRecord
โ Accesses the transaction triggering the GL plugin (e.g., Invoice, Sales Order).context.standardLines.iterator()
โ Iterates through the default GL lines created by NetSuite.line.setCreditAmount(0)
โ Neutralizes the original credit line so it wonโt double-post.context.lines.addNewLine()
โ Adds your custom GL line.- Error Handling โ
try...catch
block logs errors safely.
๐น Example Use Cases
- Multi-Subsidiary Accounting โ Redirect revenue/expense accounts per subsidiary.
- Tax Adjustments โ Add custom lines for tax reporting.
- Commission Splits โ Post additional GL entries for sales commissions.
- Deferred Revenue โ Move revenue into deferral accounts dynamically.
๐น Best Practices
โ
Always neutralize standard lines if you replace them.
โ
Test thoroughly in sandbox before production.
โ
Keep plug-ins modular so you can maintain easily.
โ
Add logs and error handling for traceability.
โ Summary
Custom GL Plug-ins are powerful for tailoring NetSuiteโs accounting engine. They allow businesses to override, add, or redirect accounting lines automatically, ensuring compliance and accuracy without manual intervention.
Leave a Reply