NetSuite - Sorting Line Items

十年热恋 提交于 2019-12-13 06:00:14

问题


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.


回答1:


Aside from performance concerns, there is an overriding issues that you cannot/must not "sort" lines once the line has a fulfillment or Invoice connected to it. So, you can only sort while the SO has nothing tied to it.

The reason is that you can't "move" line items - you'd have to erase it and re-add the item on a different line. Doing this will break hidden, inaccessible links NS maintains between the SO lines and subsequent transactions.

If you want to print a transaction report on created PO / SO, one common alternative is to sort the printed document only. Using nlapiXmlToPDF(), you create the PDF output in whatever order you want. This has some drawbacks as well, as the standard PDF and relating processes to rpint it can no longer be used, but this is better than sorting the actual lines.

One other approach is providing two sublists in the UI. The real NS sublist, which you don't sort, and a "fake" sublist maintained and sorted, using a widget that does allow sorting (perhaps going as far as a nifty Ext JS UI component, etc). The problem here is of course maintaining content synch between the two sublists, but as bad as that sounds in most cases it's STILL better than true sorting of the real sublist.

Reference : Scripted Sales Order Sorting: Suggestions



来源:https://stackoverflow.com/questions/31931779/netsuite-sorting-line-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!