0
    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']


                  ];

我有一个搜索,我正在运行以获得结果。我需要使用表达式,因为我需要在过滤器中有一个“或”。因此,在 UI 中,我构建了搜索并产生了正确的结果。我得到 7 个结果。现在在我的代码中,当我提醒搜索结果时,我得到 6,这意味着它没有执行代码的“或”部分。我似乎无法弄清楚如何使用“或”。第一次在代码中使用表达式,因此修复它可能是一件简单的事情。我已经以各种可能的方式尝试了括号。有没有人有任何解决方案?提前致谢!

4

1 回答 1

0

如果您的搜索在 UI 中正常工作,您可以尝试通过加载搜索然后在代码中使用它来获取代码中的过滤器表达式。

x = nlapiLoadSearch(null, YOUR_UI_SEARCH_ID);
y = nlapiSearchRecord(YOUR_CUSTOM_RECORD_ID, null, x.getFilterExpression());

yx应该产生与UI中相同的结果。您还可以查看x.getFilterExpression()与您的过滤器表达式匹配的内容。

此外,如果您对自己在代码中执行/匹配过滤器表达式不感兴趣,您可以使用下面的代码来获取结果

nlapiLoadSearch(null, YOUR_UI_SEARCH_ID).runSearch().getResults(0, 1000);
于 2015-12-15T03:23:59.397 回答