域名已变更 请手动修改文章中域名指向carlzeng.com

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

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。

 

 

posted @ 2014-10-23 10:00  CarlZeng  阅读(628)  评论(0编辑  收藏  举报
域名已变更 请手动修改文章中域名指向carlzeng.com