“RECALC” Replaced by “SUBLISTCHANGED”

Before we wrap up, there is one important change to SuiteScript 2.0 Client Scripts that impacts how we work with sublists.

In 1.0 Client Scripts, there is an event called recalc. This event fires whenever a change has been made to a sublist that impacts the total of a transaction.

Let’s say you are editing a Sales Order in the UI, and you adjust the Quantity of a line. That change will obviously change the total of the order, so NetSuite will fire the recalc event to any Client Scripts. However, if instead of changing the quantity, you changed something that did not impact the total, like perhaps the Location or the Item Description, then NetSuite would not fire recalc. This made it problematic to detect and handle changes to sublists that did not impact the total of a transaction.

In 2.0, there is no longer a recalc event on Client Scripts. It has been replaced by an event named sublistChanged. Unlike recalc, this event gets fired whenever any line change has been committed, regardless of what that change was. Whether you are inserting, removing, adding, or modifying a line, and no matter which columns you modify, this new event will get fired as soon as you commit that line change. This is much less confusing than recalc, and it allows us to build far more robust sublist interactions in our Client Scripts.

Leave a comment

Your email address will not be published. Required fields are marked *