我想在“N/Search”模块中使用括号添加过滤条件。
我在 Netsuite 保存的搜索选项(用户界面)中添加了带有条件的括号“()”,但我没有在“SuiteScript 2.0 版本”过滤器数组中添加括号内的条件。
我想在括号内添加条件,如下图所示:
[![如何在过滤器数组上使用括号过滤条件(SuiteScript)][1]][1]
我的代码:
filters = [
['custrecord_employee_name', 'is', employeeId], 'AND'
['custrecord_item_category', 'is', ItemCategoryId], 'AND',
['custrecord_commissions_owner', 'is', BookOwnerID], 'AND',
['custrecord_form', 'is', formId], 'AND',
(
['custrecord_from_date', 'onorbefore', createdDate], 'OR'
['custrecord_from_date', 'onorafter', createdDate]
), 'AND',
(
['custrecord_end_date', 'onorbefore', endDate], 'OR',
['custrecord_end_date', 'onorafter', endDate]
)
];
最佳答案
使用过滤表达式时,您可以将条件与新的数组层分组在一起。在代码中,只需用方括号替换括号即可。另外,请确保您已声明 filters
与 var
在你的函数中的某个地方,这样它就不是全局的。
var filters = [ /* use var to avoid global */
['custrecord_employee_name', 'is', employeeId], 'AND'
['custrecord_item_category', 'is', ItemCategoryId], 'AND',
['custrecord_commissions_owner', 'is', BookOwnerID], 'AND',
['custrecord_form', 'is', formId], 'AND',
[ /* array here instead of parens */
['custrecord_from_date', 'onorbefore', createdDate], 'OR'
['custrecord_from_date', 'onorafter', createdDate]
], 'AND',
[ /* and again here */
['custrecord_end_date', 'onorbefore', endDate], 'OR',
['custrecord_end_date', 'onorafter', endDate]
]
];
尽管如此,我不太确定您的日期过滤器正在完成什么任务。对于两者createdDate
和endDate
,看起来它们可以是 on
中的任何一个, before
,或after
它们在记录上的相应字段,基本上是任何日期。
您实际上尝试使用这些过滤器检索什么?
关于javascript - 如何在 'N/search'模块过滤器中添加带括号的过滤条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38693023/