This article is relevant to NetSuite users that want to enhance logic on their forms.
Minimize Errors with Good Input Controls
In my days as a Certified Public Accountant, my orientation was around controls and information reliability. Naturally, anything that could be done to help prevent the “garbage in, garbage out” phenomenon was welcomed.
When entering bills in NetSuite, a simple control is to count up the quantities of the line items. For example, suppose you are a tire store and you are buying a number of tires of different sizes each with a different line item. You know you bought 100 tires but they are scattered across 5 lines. A total quantity will help you see that you have entered a total of 100 items to prevent input errors.
This use case can work on sales orders, item receipts, vendor bills, and pretty much where ever you have header and line item information.
Leverage NetSuite SuiteScript
I thought this would be a good example of how to use NetSuite SuiteScript to achieve the objective. It should be straight forward enough for beginners to understand. I will not go into how to install the script through deployments — instead, the code sample can be used as a template for your logic.
Code up Custom Quantity Field
Instead of creating a permanent custom field, dynamically generate a field that lives only when the form is loaded. Code this up to UserEvent BeforeLoad event.
function VendorBillUserEventBeforeLoad(type, form, request){ if (type != 'delete'){ var itemqty = form.addField('custpage_item_qty_total', 'float', 'Sum Item Quantity:', null, 'items'); itemqty.setDisplaySize(10); itemqty.setDisplayType('inline'); }; };
Code up Summing Logic
Now use this client code snippet on the Recalc event.
function VendorBillRecalc(type){ var qty = 0; for ( var i = 1; i <= nlapiGetLineItemCount('item'); i++ ) { qty = qty + parseFloat(nlapiGetLineItemValue('item', 'quantity', i)); }; nlapiSetFieldValue('custpage_item_qty_total', qty); };
Summary
If you want to optimize NetSuite, contact us and we can help.