Reputation: 771
I want to add the filter conditions using the parenthesis in 'N/Search 'Module.
I'm getting the adding of parenthesis "()" with conditions in Netsuite Saved Search Options (IN User Interfaces) but i'm not getting the adding of conditions within parenthesis in the "SuiteScript 2.0 version" Filter Arrays.
I want add the conditions within the parenthesis like this on the below image:
[![How to filter conditions with the parenthesis on the filter array(SuiteScript)][1]][1]
My Code:
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]
)
];
Upvotes: 0
Views: 1470
Reputation: 8902
When using filter expressions, you group conditions together with new layers of Arrays. In your code, you simply replace your parentheses with square brackets. Also, make sure you have declared filters
with var
somewhere in your function so that it is not global.
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]
]
];
All that said, I am not quite sure what your date filters are accomplishing. For both createdDate
and endDate
, it looks like they can be any of on
, before
, or after
their corresponding field on the record, which is basically any date at all.
What is it that you are actually trying to retrieve with these filters?
Upvotes: 3