ANS-0855 · SUITESCRIPT DEVELOPMENT
How to Avoid NetSuite ‘Add Item’ Warning in Client-Side Scripts
Using the 'sublistChanged' entry point can resolve unwanted 'Add Item' warnings during client-side sublist recalculations.
Short answer
To prevent the NetSuite 'Add Item' warning when recalculating sublist fields in a client-side script, implement the recalculation logic within the 'sublistChanged' entry point. Avoid using the 'fieldChanged' trigger for this specific scenario. This ensures proper handling of sublist modifications without creating a new blank line that prompts the warning.
Scenario
A client-side script is designed to iterate through all line items on a transaction and recalculate a specific field whenever any item field is modified. When the script processes the last line item and commits it, NetSuite automatically creates a new, blank line. This action triggers an 'Add Item' warning message if the user attempts any further actions on the transaction, disrupting the workflow. Attempts to programmatically cancel the new line using SuiteScript 2.x functions like 'currentRecord.cancelLine(options)' proved ineffective.
Solution
The effective solution involves adjusting the client-side script's entry point for the recalculation logic.
Do not implement the line item recalculation method within the 'fieldChanged' entry point.
Instead, implement the recalculation logic within the 'sublistChanged' entry point.This approach ensures that the script correctly handles sublist modifications without inadvertently creating a new blank line item, thereby preventing the 'Add Item' warning message.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
