Conditional Filters for Query module?

For saved searches filters are defined as arrays or arrays of arrays if you use complicated “AND”, “OR” operators.

In the new query module this is replaced with a function ex: myQuery.and(cond1, cond2 etc…)

With saved search filters you can simply conditionally push a filter into an array to include it in the search, is there a way to do so with the Query module? I’ve tried using “myQuery.and.apply(null, conditionsArray)” with no success

Beginner Asked on November 20, 2019 in SuiteScript.
Add Comment
1 Answer(s)
Best answer

Try using this as the first argument

mainQuery.condition = mainQuery.and.apply(this, [Condition1, Condition2, Condition3])


worked for me

Intermediate Answered on November 21, 2019.

Actually I just tried null and that worked as well…can you provide more details about your query and what error you were getting? 🙂

on November 21, 2019.

Yeah I must have fat fingered something cause both are working for me today as well 🙂

on November 21, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor