suitescript dynamic saved search filter
# ask-stanley-ai
k
suitescript dynamic saved search filter
c
AI generated answer (using internal Slack threads):
In SuiteScript, when you load a saved search using its ID, the filters saved with the search also get loaded. If you want to add additional filters, you should push new filters to the existing array, not overwrite it. Here's an example:
Copy code
javascript
var mySearch = search.load({
    id: 'customsearch_my_saved_search'
});

var myFilter = search.createFilter({
    name: 'custrecord_my_field',
    operator: search.Operator.ANYOF,
    values: ['1', '2', '3']
});

mySearch.filters.push(myFilter);
In the context of a Suitelet, you can use the N/search module to load and run the saved search, and the N/ui/serverWidget module to create a form and add fields to it. However, there isn't a native way to filter the results in your sublist with NetSuite APIs. You might need to deploy a client script to your page and hide lines with jQuery, but this goes beyond the normal scope of a Suitelet. If you're having trouble with the search criteria not being applied when running a saved search via SuiteScript, make sure you're using
search.load
to get the search. This should load both the filter criteria and the result columns defined in the UI saved search. If you're still having issues, you might need to recreate the search in code. ****** 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.865356326
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861389041
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85925293
Please provide your feedback on this answer.