HELLO ALL, WHAT IS WRONG WITH THIS, i want two fil...
# suitescript
v
HELLO ALL, WHAT IS WRONG WITH THIS, i want two filters and then those two be combined with "AND" OPERATOR loadedSearch.filters.push(search.createFilter({ [name : 'subsidiary', operator: 'anyof', values: represent_subsidiary] "AND" ["representingsubsidiary","anyof","internalid_subsidiary:"] })); GETTING AN ERROR.
d
you need to wrap your
values
filterExpression in additional brackets [] so is of type
string[]
Edit: misread code initially, this would apply instead to
filters
argument of new Search being initialized instead
v
sorry i dont understand this. i need filter1 -->[name : 'subsidiary', operator: 'anyof', values: represent_subsidiary] AND filter2 --> ["representingsubsidiary","anyof","internalid_subsidiary:"]
how can this be achieved?
d
typically when initializing the search you can just have everything in one filterExpression combined with "AND" in between but if you need to add dynamically after the fact, I think from your example should be able to just do something like
Copy code
loadedSearch.filters.push(search.createFilter({
    name: 'subsidiary',
    operator: 'anyof',
    values: represent_subsidiary
}));

loadedSearch.filters.push(search.createFilter({
    name: 'representingsubsidiary',
    operator: 'anyof',
    values: internalid_subsidiary
}));
☝️ 1
v
but its initally i am loading a search and then adding the filter
d
ok then then try the above suggestion. when pushing new filters, should automatically combine and apply logic as "AND"
e
1. install this chrome extension
Then create a saved search (be sure to actually save it) and go ahead and click on the link to view the code to generate the search. you’ll see a filter expression in there
v
Thank you