ANS-0916 · SUITESCRIPT DEVELOPMENT
How to Filter for Empty List/Record Fields in NetSuite Scripted Searches
Learn the correct SuiteScript 2.0 method to identify records where a specific list or record field is empty using the '@NONE@' value.
Short answer
To find empty list or record fields in NetSuite scripted searches, use the '@NONE@' value with the ANYOF or NONEOF operator. In SuiteScript 2.0, this is achieved using search.createFilter with the field's internal ID and search.Operator.ANYOF or search.Operator.NONEOF for the values: ['@NONE@'] parameter.
Scenario
Users often need to identify records in NetSuite where a specific list or record field has no value assigned. This requirement commonly arises when performing data cleanup, reporting, or automating processes that depend on the presence or absence of linked records or selections. Standard search filters might not intuitively reveal how to target these empty fields within a scripted context.
Solution
To identify records where a specific list or record field is empty within a NetSuite scripted search, use the '@NONE@' value with the ANYOF or NONEOF operator. In SuiteScript 2.0, this is accomplished by creating a search filter using the search.createFilter method.
Ensure your SuiteScript 2.0 script loads the N/search module.
Construct the filter using the field's internal ID, the search.Operator.ANYOF (or NONEOF) operator, and ['@NONE@'] as the values.For example, to find records where the custrecord_fabrication_wo_linked field is empty:
javascript/** * @NApiVersion 2.x * @NModuleScope SameAccount */define(['N/search'], function(search) { // ... your script logic ... var emptyFieldFilter = search.createFilter({ name: 'custrecord_fabrication_wo_linked', operator: search.Operator.ANYOF, values: ['@NONE@'] }); // This filter can then be added to a search.create or search.load operation. // Example: // var mySearch = search.create({ // type: search.Type.TRANSACTION, // filters: [emptyFieldFilter], // columns: ['internalid'] // }); // ...});This filter effectively targets records where the specified list/record field has no value selected.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
