I would like to create an User Event script (Before Submit event), applied on Transactions (Purchase Orders, Sales Orders) that will Sort the Items lines based on a certain field (i.e. Item Name).
My approach would be to store all information in an array, sort it and then use the APIs nlapiRemoveLineItem method to remove each item and nlapiInsertLineItem method to insert each item on the correct order.
However, for this approach I would need to store all columns values before removing and inserting, and my concern is that NetSuite may raise an error due to any specific validation when inserting the line or when submitting the record.
Is there any different approach to make easier sorting the Line Items? Any suggestion would be highly appreciated.