NetSuite-对订单项进行排序 [英] NetSuite - Sorting Line Items

查看:172
本文介绍了NetSuite-对订单项进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个用户事件脚本(在提交事件"之前),该脚本应用于交易(采购订单,销售订单),该脚本将基于特定字段(即项目名称")对项目"行进行排序.

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).

我的方法是将所有信息存储在一个数组中,对其进行排序,然后使用API​​ nlapiRemoveLineItem 方法删除每个项目,然后使用 nlapiInsertLineItem 方法在其中插入每个项目正确的顺序.

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.

但是,对于这种方法,我将需要在删除和插入之前存储所有列的值,而且我担心的是,由于在插入行或提交记录时进行任何特定的验证,NetSuite可能会引发错误.

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.

推荐答案

除了性能方面的问题外,还有一个最重要的问题,即一旦该行有履行或发票连接到该行,您就不能/必须不对这些行进行排序".因此,您只能在SO没有任何关联的情况下进行排序.

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.

原因是您不能移动"订单项-您必须删除它,然后将其重新添加到其他行中.这样做会破坏NS在SO行和后续事务之间维持的隐藏的,无法访问的链接.

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.

如果要在已创建的PO/SO上打印交易报告,一种常见的替代方法是仅对打印的文档进行排序.使用nlapiXmlToPDF(),可以按所需顺序创建PDF输出.这也有一些缺点,因为不再能够使用标准PDF及其与rpint相关的过程,但这比对实际的行进行排序要好.

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.

另一种方法是在UI中提供两个子列表.真正的NS子列表(无需排序)和假"子列表可使用允许排序的小部件进行维护和排序(可能会扩展到漂亮的Ext JS UI组件等).当然,这里的问题是保持两个子列表之间的内容同步,但是听起来很糟糕,在大多数情况下还是比对真实子列表的真实排序要好.

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.

参考:: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆