Netsuite SuiteScript 2.0 search.create返回空结果
我正在尝试获取在创建新销售订单时等待完成的所有销售订单。这是为了提醒用户销售订单已在进行中。我使用的代码就是这样的Netsuite SuiteScript 2.0 search.create返回空结果,netsuite,suitescript2.0,Netsuite,Suitescript2.0,我正在尝试获取在创建新销售订单时等待完成的所有销售订单。这是为了提醒用户销售订单已在进行中。我使用的代码就是这样的 function saleOrderInPendingFulfillmentAlreadyExists(scriptContext) { //Check if the customer already has an order which is pending fulfillment debugger; var idC
function saleOrderInPendingFulfillmentAlreadyExists(scriptContext)
{
//Check if the customer already has an order which is pending fulfillment
debugger;
var idCustomer = scriptContext.currentRecord.getValue('entity');
var recCustomer;
if(idCustomer)
{
var filters = [
["mainline", "is", "T"], "and",
["type", "anyOf", search.Type.SALES_ORDER], "and",
["entity", "anyOf", idCustomer],
];
var columns = [ "tranid" ];
var searchQuery = search.create({
"type": search.Type.TRANSACTION,
"filters": filters,
"columns": columns
});
var salesorders = searchQuery.run().getRange({"start": 0, "end": 1000}) || [];
}
}
调试代码时,变量salesorders是一个空数组,但我知道客户文件上至少有8个销售订单。我做错了什么?您的问题是
类型
搜索筛选器希望记录的格式与搜索的格式不同。类型
枚举('SalesOrd'
而不是'SalesOrd'
)。欢迎使用NetSuite
您可以将过滤器更改为
var filters = [
["mainline", "is", "T"], "and",
["type", "anyOf", 'SalesOrd'], "and",
["entity", "anyOf", idCustomer],
];
或者,甚至更好
var searchQuery = search.create({
"type": search.Type.SALES_ORDER,
"filters": filters,
"columns": columns
});
顺便说一句,您一定要查看,它允许您在UI中构建搜索并自动将其转换为SuiteScript。因此,如果我使用第二个选项,这是否意味着类型筛选器不需要存在?@TomHanson正确