The quick answer
Array.concat returns a new array. Assign the combined array to the loaded search's filters property before calling run. Use internal-ID variables for select filters, and preserve the loaded criteria. A runtime change does not alter the saved search definition unless you explicitly save it.
This walkthrough executes the supplied JavaScript source against a local N/search stand-in. Its separate synthetic saved-search UI evaluates the same prepared records independently. No native account execution, engine validation, deployment permissions, scheduled job, PDF generation or email delivery is verified. The forum source had further unresolved issues; this guide isolates two concrete defects.
Before you start
The prepared Active Item Lookup saved search has one criterion: Inactive is false. Four fictional items provide the input: three active, one inactive. This walkthrough's loaded baseline has a populated filters property. For an unfiltered search, handle a null filters value before calling concat. The selected item is 1452, Pressure Manifold; its representative Inspection Group has ID 7, Field Equipment. Use real field definitions, field types and internal IDs for account testing.
The example's custitem_inspection_group represents a List/Record field. It and internalid use ANYOF with ID values. The UI label Inactive corresponds to isinactive in SuiteScript. The local model's validation and error text are deliberately limited; they do not predict NetSuite's exact handling of invalid filter values.
01. Inspect the saved baseline
Open Active Item Lookup results. The separately evaluated saved-search UI returns three active items: Pressure Manifold, Valve Housing and Service Coupling. Click Edit this Search and inspect the sole Inactive is false criterion.
02. Find the unattached array
Open item_search.js in the local Code Editor. It loads the search, creates two extra Filter objects, and combines them with the base filters:
const baseFilters = itemSearch.filters;
const filtersWithExtras = baseFilters.concat(extraFilters);
That expression creates a new array. It does not assign it to itemSearch.filters. Array.concat leaves the existing array unchanged.
Click Run local harness. The actual source reports Prepared filters: 3, but the search object still has Attached filters: 1. Its local result contains three rows. Logging the combined array did not attach it.
03. Attach the filters
Replace the attachment comment with:
itemSearch.filters = filtersWithExtras;
Each harness run freshly loads the base search. The combined array is assigned once; the extra filters do not accumulate between runs.
Run the harness again. It now has three attached filters, but rejects item as an unknown numeric internal ID. The code contains values: ['item'], which passes literal text. This model-specific diagnostic is not a promised native exception, and a failed run is not a valid zero-result search.
04. Use the selected IDs
Change values: ['item'] to values: [item], and values: ['group'] to values: [group]. The variables already contain the fictional IDs 1452 and 7. Keep the assignment and loaded base criterion.
The final request-specific filtering sequence is:
const item = '1452';
const group = '7';
const itemSearch = search.load({id: 'customsearch_active_items'});
const extraFilters = [
search.createFilter({
name: 'internalid', operator: search.Operator.ANYOF,
values: [item]
}),
search.createFilter({
name: 'custitem_inspection_group', operator: search.Operator.ANYOF,
values: [group]
})
];
const baseFilters = itemSearch.filters;
const filtersWithExtras = baseFilters.concat(extraFilters);
itemSearch.filters = filtersWithExtras;
const rows = itemSearch.run().getRange({start: 0, end: 100});
Run the local harness. Confirm Attached filters: 3, Result rows: 1, and 1452 · Pressure Manifold. The input records are prepared; the result is computed by the stand-in.
05. Save and rerun
Click Save, reload the editor, and Run local harness again. It returns the same one-row local result. This checks retained local file bytes. It does not upload to the File Cabinet, deploy a script or update a saved-search definition.
06. Recheck the saved definition
Reopen Active Item Lookup results. The independent saved-search UI still returns three active items. Click Edit this Search: its only saved criterion remains Inactive is false. No Save or Save & Run action is used on this form.
The one-row local output was never written into this result grid. The extra filters belonged to the runtime object, and the code never called itemSearch.save(). The local editor’s Save retains source bytes; it does not call that API.
Common questions
Why do logged filters look correct while results stay unchanged?
A log of a newly concatenated local array does not show which array is attached to the search object. Assign it to Search.filters before running the loaded object. Also verify field IDs, operators and values independently.
Why is ['item'] different from [item]?
The quoted version is the literal text item. The unquoted version evaluates the variable. For select fields, search.createFilter requires the appropriate internal ID values rather than display labels. Do not assume an ANYOF operator suits every field type.
Should I insert AND into an array of Filter objects?
No. Filter objects supplied through the Search.filters array use implicit AND. Use filterExpression for explicit AND/OR and nested grouping. This lesson's base criterion is a simple conjunction; flattening a loaded OR expression can change its meaning.
Does the runtime repair change the saved search?
No saved definition is changed here. The code modifies only the freshly loaded object and runs it. Request-specific filters usually should stay runtime-only. Saving the search is a separate, deliberate action.
Is the first 100 rows a complete report?
No. The getRange call is a bounded demonstration. Design pagination, governance, stable sorting and error handling separately for production. The source's scheduling, PDF and email workflow is outside this walkthrough.
Does results.map fix the filters?
No. map returns another JavaScript array; ignoring that return value leaves the original results array unchanged. Capturing mapped result data is a separate issue from attaching filters.