Netsuite:使用基于所选交易(采购订单)的项目填充字段

Netsuite: Populate Field with Items based on Chosen Transaction (Purchase Order)

有没有办法通过选定的采购订单(交易)过滤字段中列出的项目,即用户选择采购订单,然后使用该采购订单上的项目列表填充项目字段?

抱歉,如果这是一个非常简单的问题,但我搜索了所有地方,但我找不到确切的场景。在文档中也找不到它。我会继续努力,但如果有人知道,将不胜感激!

可以使用 Suitescript。

您需要使用用户事件脚本向 beforeLoad 上的表单动态插入自定义 select 字段,我们称之为 custpage_mycustomfield

然后您需要一个客户端脚本来填充 custpage_mycustomfield 上的项目列表,这需要在 PO 字段更改后发生。您可以 运行 搜索或加载记录以获取订单项。

您在 custpage_mycustomfield 中输入的数据不会被保存,因此如果您想保留它,您需要执行以下操作:

  1. 使用类型为 List/Record 的 UI 创建自定义字段 > 项目,我们称之为 custbody_mypermanentfield

  2. saveRecord 上将 clientscript 函数设置为 运行,这将复制 值 select 从 custpage_mycustomfield 变为 custbody_mypermanentfield

我知道这已经很老了,但我认为更可靠的解决方案是使用自定义表单上可用的已保存搜索过滤器。

从管理中心 --> 自定义 --> 表单 --> 交易表单 --> "Your Form" --> 编辑

子列表字段选项卡下是项目搜索的下拉菜单。您只需 select 一个根据您的需要限制下拉列表的搜索。

所有这些都可以在 PO 字段的 fieldChanged 事件中从客户端脚本完成。首先,在 PO 上应用搜索并获取所有子列表项目列表,然后删除项目字段的所有 select 选项,然后在此字段上添加 PO 的子列表项目列表。

function fieldChanged(context){
var currRec = context.currentRecord;

// search on PO to get sublist items
var itemSearch = search.create({
    type: 'purchaseorder',
    filter: ['internalid', 'is', '<your PO id>'],
    columns: ['item']
}).run().getRange(0,100);

var poItemList = [];
itemSearch.forEach(function(result){
    if (result.getValue({name: 'item'})) {
        poItemList.push = { value: result.getValue({name: 'item'}), text: result.getText({name: 'item'})};
}
})

//remove all options of item field
var itemField = currRec.getField({fieldId: '<your custom field>'});
itemField.removeSelectOption({value: null}) //this removes all options

//add sublist items in item field options
poItemList.forEach(function(item){
    itemField.addSelectOption(item);
})}

希望对您有所帮助!!