netsuite suitescript 过滤器表达式未产生所需的搜索结果
netsuite suitescript filter expression not producing the search results needed
var filterExp = [
[ ['custrecord_rebate_customer.isinactive', 'is', 'F'],
'and',
['custrecord_rebate_customer.custrecord_start_date', 'before', date],
'and',
['custrecord_rebate_customer.custrecord_end_date', 'after', date],
'and',
['custrecord_rebate_customer.custrecord_upaya_warehouse', 'anyof', warehouse],
'and',
['isinactive', 'is', 'F' ],
'and',
['custrecord_customer_name', 'anyof', customer]],
'or',
['custrecord_rebate_customer.custrecord_global_clearance_item','is','T']
];
我有一个搜索,我正在运行得到结果。我需要使用一个表达式,因为我需要在过滤器中有一个 "or"。所以在 UI 中我建立了搜索并且它产生了正确的结果。我得到 7 个结果。现在在我的代码中,当我提醒搜索结果时,我得到 6,这意味着它无法执行代码的 "or" 部分。我似乎不知道如何使用 "or"。第一次在代码中使用表达式,因此修复起来可能很简单。我已经以各种可能的方式尝试了括号。有没有人有任何解决方案?提前致谢!
如果您的搜索在 UI 中工作正常,您可以通过加载搜索然后在您的代码中使用它来尝试在代码中获取过滤器表达式。
x = nlapiLoadSearch(null, YOUR_UI_SEARCH_ID);
y = nlapiSearchRecord(YOUR_CUSTOM_RECORD_ID, null, x.getFilterExpression());
y
应该产生与 UI 中的 x
相同的结果。您还可以查看 x.getFilterExpression()
的内容以匹配您的过滤器表达式。
此外,如果您对自己在代码中 doing/matching 过滤表达式不感兴趣,您可以使用以下代码获取结果
nlapiLoadSearch(null, YOUR_UI_SEARCH_ID).runSearch().getResults(0, 1000);
var filterExp = [
[ ['custrecord_rebate_customer.isinactive', 'is', 'F'],
'and',
['custrecord_rebate_customer.custrecord_start_date', 'before', date],
'and',
['custrecord_rebate_customer.custrecord_end_date', 'after', date],
'and',
['custrecord_rebate_customer.custrecord_upaya_warehouse', 'anyof', warehouse],
'and',
['isinactive', 'is', 'F' ],
'and',
['custrecord_customer_name', 'anyof', customer]],
'or',
['custrecord_rebate_customer.custrecord_global_clearance_item','is','T']
];
我有一个搜索,我正在运行得到结果。我需要使用一个表达式,因为我需要在过滤器中有一个 "or"。所以在 UI 中我建立了搜索并且它产生了正确的结果。我得到 7 个结果。现在在我的代码中,当我提醒搜索结果时,我得到 6,这意味着它无法执行代码的 "or" 部分。我似乎不知道如何使用 "or"。第一次在代码中使用表达式,因此修复起来可能很简单。我已经以各种可能的方式尝试了括号。有没有人有任何解决方案?提前致谢!
如果您的搜索在 UI 中工作正常,您可以通过加载搜索然后在您的代码中使用它来尝试在代码中获取过滤器表达式。
x = nlapiLoadSearch(null, YOUR_UI_SEARCH_ID);
y = nlapiSearchRecord(YOUR_CUSTOM_RECORD_ID, null, x.getFilterExpression());
y
应该产生与 UI 中的 x
相同的结果。您还可以查看 x.getFilterExpression()
的内容以匹配您的过滤器表达式。
此外,如果您对自己在代码中 doing/matching 过滤表达式不感兴趣,您可以使用以下代码获取结果
nlapiLoadSearch(null, YOUR_UI_SEARCH_ID).runSearch().getResults(0, 1000);