Netsuite SuiteScript > Search Advance feature,搜索中使用 'OR' operation-CarlZeng

Sample in online help//Define search filter expressionvar filterExpression = [ [ ‘trandate’, ‘onOrAfter’, ‘daysAgo90’ ], ‘or’, [ ‘projecte…

Sample in online help

//Define search filter expression

var filterExpression = [ [ ‘trandate’, ‘onOrAfter’, ‘daysAgo90’ ],
‘or’,
      [ ‘projectedamount’, ‘between’, 1000, 100000 ],
‘or’,
‘not’, [‘customer.salesrep’, ‘anyOf’, -5 ] ] ;

//Define search columns
var columns = new Array();
columns[0] = new nlobjSearchColumn(‘salesrep’);
columns[1] = new nlobjSearchColumn(‘expectedclosedate’);
columns[2] = new nlobjSearchColumn(‘entity’);

//Execute the search. You must specify the internal ID of the record type.
var searchresults = nlapiSearchRecord(‘opportunity’, null, filterExpression, columns);

由于nlobjSearchFilter默认发出的都是‘AND’的指令,所以这个api,无法完成or的操作。

By default, search filter list (nlobjSearchFilter[]) makes use only of an implicit ‘AND’ operator for filters. This is contrary to search filter expression that can explicitly use either ‘AND’ or ‘OR’ operators.

[ ‘trandate’, ‘onOrAfter’, ‘daysAgo90’ ],
‘or’,
[ ‘projectedamount’, ‘between’, 1000, 100000 ],

这种操作参数,直接不适用nlobjSearchFilter,而且没有reference其他record的功能;
整个API还是低于UI的USE EXPRESSIONS功能的。
所以另外方案
1。在UI上定义这类OR或者或者包含Parens的Search,然后suitescript去直接调用结果。
2。使用多个Search,消耗更多的unit来实现复杂的单个Search。

个性化需求沟通 扫客服加V加群: