0

我的代码是这样的:

var filters = new Array();

        filters[0] = new nlobjSearchFilter("isperson", "customer", "is", "F")

        filters[1] =  new nlobjSearchFilter([["minimumquantity", "equalto", "0"], "OR", ["minimumquantity", "isempty", ""]]);

        
        if (customerId) filters.push(new nlobjSearchFilter("customer", null, "anyof", customerId));
        if (currency) filters.push(new nlobjSearchFilter("currency", null, "anyof", currency)); 

我的问题是如何使过滤器[1] 与“或”运算符一起使用?

4

1 回答 1

0

您在“或”条件下处于正确的轨道上。

我不知道您要查询哪条记录,但是在构建搜索时控制多个和/或条件的最简单方法是使用搜索“过滤器表达式”而不是手动构建nlobjSearchFilter().

如果您想继续使用nlobjSearchFilter(),请查看如何使用.setLeftParens()/.setRightParens().setOr()功能(示例)。NetSuite 帮助中没有记录它们)。

var filters = [
    // this is how joins are referenced in filter expressions
    // this is equivalent to nlobjSearchFilter('isperson', 'customer', 'is', 'F')
    ['customer.isperson', 'is', 'F'],
    'and', [
        ['minimumquantity', 'equalto', 0], 'or', ['minimumquantity', 'isempty', null]
    ],
];

if (customerId) filters.push('and', ['customer', 'anyof', customerId]);
if (currencyId) filters.push('and', ['currency', 'anyof', currency]);
于 2021-05-13T17:31:43.683 回答