quick question - how do you group filters together...
# suitescript
t
quick question - how do you group filters together in the search filter list? Ex: (condition_a || condition_b) && condition_c
I tried doing a sub-array [["condition_a"], "OR", ["condition_b"]], "AND", ["condition_c"] but that gave an error
s
wrap them all in an outer enclosing array
a
[ [conditionA,"is",value], "AND", [conditionb,"is",value], "AND", [conditionA, "is", value] ]
s
[[["condition_a"], "OR", ["condition_b"]], "AND", ["condition_c"]]
t
I tried it like this: [ [ ["value_a", "is", "T"], "OR" ["value_b", "is", "T"], ], "AND", ["value_c", "is", "F"] ]
And I get: Wrong parameter type: filters is expected as Array.
s
there's a trailing comma on the value_b line
t
removed that and same error
If I remove the sub-array it works fine so that is where the error is coming from
s
it's definitely the subarray. there needs to be a comma after the "OR" as well
👍 1
I have been using an auto-formatter (Prettier) which helps with formatting complex, nested arrays like this.
t
Bah that was it
thank you
s
Sure. I'd highly recommend using a formatter. I don't know how I ever got along before that. It's so easy to make syntax errors, and takes forever to spot them.
now i don't worry about it 😀
t
good idea, thanks