在 Netsuite 中,销售订单记录类型包含一个名为“ shipaddresslist ”的字段,其中包含与所选客户地址关联的客户地址内部 ID。
不幸的是,没有销售订单的搜索列会得到“ shipaddresslist ”的值,所以我必须找到一个解决方法。
使用 SuiteScript,我已经能够通过遍历搜索结果、将销售订单 ID 传递给 record.Load() 函数并在加载的记录上调用 record.getValue() 来获取此字段的值,如如下图
搜索:
var salesorderSearchObj = search.create({
type: "salesorder",
filters:
[
["type","anyof","SalesOrd"],
"AND",
["item.isfulfillable","is","T"],
"AND",
["status","anyof","SalesOrd:B","SalesOrd:E","SalesOrd:D"],
"AND",
["quantitycommitted","greaterthanorequalto","1"],
"AND",
["location","anyof","1","3"],
"AND",
["mainline","is","F"],
"AND",
["item.type","anyof","InvtPart"]
],
columns:
[
search.createColumn({
name: "transactionnumber",
sort: search.Sort.ASC,
label: "Transaction Number"
}),
search.createColumn({name: "entity", label: "Name"}),
search.createColumn({
name: "custcol8",
sort: search.Sort.ASC,
label: "JANコード"
}),
search.createColumn({name: "quantityuom", label: "Quantity in Transaction Units"}),
search.createColumn({name: "statusref", label: "Status"}),
search.createColumn({
name: "quantityonhand",
join: "item",
label: "On Hand"
}),
search.createColumn({
name: "isfulfillable",
join: "item",
label: "Can be Fulfilled"
}),
search.createColumn({name: "department", label: "Department"}),
search.createColumn({name: "otherrefnum", label: "PO/Cheque Number"}),
]
});
循环和记录加载:
var matches = [];
salesorderSearchObj.run().each(function(result){
var objRecord = record.load({
type: record.Type.SALES_ORDER,
id: result.id,
isDynamic: true,
});
var push = resultToObject(result);
push.addressid = objRecord.getValue({fieldId:'shipaddresslist'});
log.debug("Result:",push);
matches.push(push);
return true;
});
这很好用......除了我通过搜索返回大约 1000 个销售订单,这意味着 record.Load() 在我完成搜索并构建整个结果列表之前会吃掉我的治理单元。
简而言之,有没有办法直接从搜索对象中从销售订单记录中返回“ shipaddresslist ”的值?或者可能是一种动态抓取该字段而无需加载整个记录对象的方法?
任何帮助是极大的赞赏!