<@U8CT0V220> Your approach...
# suitescript
a
@jkabot Your approach...
s
this is trying to modify the filters in-place if you use lodash it creates a copy of the collection (in this case, the collection is the filter array) so when you assign it at the end it is truly a separate copy of the filters.
a
I will use _.Clone and se how it goes..
s
in your example above,
oFilters
and
search.oFilters
always are the same reference
ok, but
filter/map
is probably better suited, to what you're actually doing as it gives you a new array and allows you to modify
j
I just searched my code and I was using search.filterExpression. It's possible search.filters behaves differently.
s
yes, I noticed
search.filterExpression
is documented as well in help
and since that is supposed to be a normal array of arrays it should be (arguably) easier to work with
I tend to do all searches using filter expressions...
j
Yeah I find it more ergonomic. But at any rate search.filterExpression is a getter / setter, and the getter gives you a deep clone of the real internal filters, so you can't modify the real internal filters array by reference.
I predict that search.filters acts the same way, but I could be wrong
b
be careful about filterExpressions
if you have to make it robust
s
how so @battk?
b
filterExpressions can have nested filter expressions in them
j
I see your point if you have to parse the filter expressions yourself (e.g. in order to remove / modify). I've only had to add to an existing list of filters.