how do you dynamically add more filter while using...
# ask-stanley-ai
a
how do you dynamically add more filter while using the saved search in suitescript
c
AI generated answer (using internal Slack threads):
To dynamically add more filters while using the saved search in SuiteScript, you can use the
filterExpression
property of the search object. Here's how you can do it: First, you need to load the saved search:
Copy code
javascript
var mySearch = search.load({
    id: 'customsearch_my_saved_search'
});
Then, get the existing filter expression:
Copy code
javascript
var existingFilters = mySearch.filterExpression;
Next, create your new filter:
Copy code
javascript
var newFilter = ['your', 'added', 'filter'];
Then, add your new filter to the existing filter expression:
Copy code
javascript
existingFilters.push(newFilter);
Finally, set the updated filter expression back to the search:
Copy code
javascript
mySearch.filterExpression = existingFilters;
Alternatively, you can use the
concat
method to add the new filter:
Copy code
javascript
mySearch.filterExpression = mySearch.filterExpression.concat(newFilter);
Please note that you can't directly call
search.filterExpression.push(newFilter);
because
search.filters
and
search.filterExpression
are getters and setters around an internal object. You need to set the
filterExpression
property rather than calling methods on it. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.869998097
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844520509
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83398515
Please provide your feedback on this answer.