ANS-0780 · SUITESCRIPT DEVELOPMENT
How to Use Internal ID for Math Filters and Columns in NetSuite Saved Searches
Understand the distinct field names required for applying mathematical filters versus specifying columns for NetSuite record internal IDs in scripts.
Short answer
When scripting NetSuite saved searches, use 'internalidnumber' for applying mathematical filters such as 'lessthan' or 'greaterthan' to an internal ID. However, when defining a column to display or aggregate the internal ID, the correct field name to use is 'internalid'. This distinction ensures proper search functionality and data retrieval.
Scenario
Users developing NetSuite scripts often need to filter saved searches based on the internal ID of records using mathematical operators (e.g., less than, greater than). A common challenge arises when attempting to use the same field name for both filtering and column specification, leading to unexpected results or errors.
Solution
To correctly apply mathematical filters to an internal ID in a NetSuite saved search script, use the field name 'internalidnumber'. Conversely, when specifying the internal ID as a column in the search results, the field name 'internalid' must be used. This ensures that filters are applied numerically and columns are correctly retrieved. Example of using 'internalidnumber' for filters and 'internalid' for columns:
searchFiltersPreviousCase[0] new nlobjSearchFilter('internalidnumber', null, 'lessthan', caseIdRejected);searchFiltersPreviousCase[1] new nlobjSearchFilter('status', null, 'is', CASE_STATUS_CLOSED, null);searchFiltersPreviousCase[2] new nlobjSearchFilter('email', null, 'isnotempty', null);searchFiltersPreviousCase[3] new nlobjSearchFilter('closeddate', null, 'onorafter', START_COUNTER_ON_DATE);searchColumnsPreviousCase[0] new nlobjSearchColumn('internalid', null, 'max');Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
