How to Bulk Add Internal IDs to a NetSuite Saved Search Using SuiteScript

By Steven Chao
Data analytics dashboard with financial charts and investment analysis visuals.

NetSuite provides a powerful saved search feature to filter and display data, but when it comes to bulk adding a list of internal IDs to a saved search, the platform doesn’t offer a very friendly way to do it via the UI. If you’ve ever tried to filter by hundreds of internal IDs manually, you know how tedious…

In this post...

Back to Blog

NetSuite provides a powerful saved search feature to filter and display data, but when it comes to bulk adding a list of internal IDs to a saved search, the platform doesn’t offer a very friendly way to do it via the UI. If you’ve ever tried to filter by hundreds of internal IDs manually, you know how tedious and error-prone it can be.

In this blog, we’ll show you why this is useful, and how to solve it with a simple SuiteScript snippet.

Why You Might Need This

Imagine you have a set of records you need to monitor, report on, or export — maybe a list of transactions, customers, or custom records. You could:

  • Export the records manually and filter them in Excel
  • Build multiple saved searches for different record sets

But both approaches are cumbersome and not maintainable. By adding a list of internal IDs directly to a saved search, you can:

  • Reuse the saved search for reporting or dashboards
  • Quickly update the search when the set of records changes

SuiteScript Snippet to Add Internal IDs

Here’s a straightforward SuiteScript snippet you can use. It loads an existing saved search and appends a filter for a list of internal IDs.

This can run in a Browser developer console with a page related library loaded, or you can adapt it to run in a Suitelet.

require(['N/search'], function(search){

const savedSearchId = '';
const ids = [];

function updateSavedSearch(savedSearchId, ids) {

try {
let mySearch = search.load({ id: savedSearchId });
let filters = mySearch.filters || [];
filters.push(
search.createFilter({
name: 'internalid',
operator: search.Operator.ANYOF,
values: ids
})
);

mySearch.filters = filters;

let newId = mySearch.save();
console.log('Saved Search Updated', `New ID: ${newId}`);
return newId;
} catch (e) {
console.error('Error updating saved search', e);
}
}

updateSavedSearch(savedSearchId,ids);

})

How to Use the Script

1.the Saved Search ID Replace the savedSearchId variable with the internal ID of your saved search. You can find this ID in the saved search URL or in the search list.
2. Prepare the List of Internal IDs Populate the ids array with the internal IDs you want to add. For example:

const ids = [101, 102, 103, 104];

3.Deploy the Script
  • You can run this script in a Suitelet, User Event, or even the Script Debugger.
  • Make sure the script has sufficient permissions to load and save the saved search.
  1. Run and Verify After running, your saved search will now include a filter for the specified internal IDs. Open the saved search in NetSuite to verify that the new filter has been added successfully.

Tips and Considerations

  • If you run this frequently or for large lists, consider using a CSV import or API to generate the IDs dynamically. It may affect performance when loading the saved search in NetSuite UI (e.g., more than 100 IDs could be slow).
  • Be careful not to overwrite existing filters unintentionally. This snippet appends a filter, preserving other filters. You can adapt the snippet to add multiple filter types (e.g., status, date ranges) if needed.

By using this approach, you can efficiently manage bulk internal ID filtering in saved searches without manual clicks or repetitive work, making your NetSuite reporting and automation much smoother.

We Are Experts at Generating ROI for our Clients Through Custom Integration of ERP Software