Search Operators
This reference lists all search.Operator and search.Summary enum values available for creating searches in SuiteScript 2.x.
Using Search Operators
define(['N/search'], function(search) {
var customerSearch = search.create({
type: search.Type.CUSTOMER,
filters: [
['email', search.Operator.ISNOTEMPTY, ''],
'AND',
['companyname', search.Operator.CONTAINS, 'Corp']
]
});
});
All Search Operators
Comparison Operators
| Operator | Description | Field Types |
|---|---|---|
EQUALTO | Exact match | All |
NOTEQUALTO | Not equal | All |
IS | Exact match (alias) | All |
ISNOT | Not equal (alias) | All |
ISEMPTY | Field is empty/null | All |
ISNOTEMPTY | Field has value | All |
Numeric Operators
| Operator | Description | Example |
|---|---|---|
GREATERTHAN | Greater than | amount > 100 |
GREATERTHANOREQUALTO | Greater than or equal | amount >= 100 |
LESSTHAN | Less than | amount < 100 |
LESSTHANOREQUALTO | Less than or equal | amount <= 100 |
BETWEEN | Within range | amount BETWEEN 100 AND 500 |
NOTBETWEEN | Outside range | amount NOT BETWEEN 100 AND 500 |
NOTGREATERTHAN | Not greater than | - |
NOTGREATERTHANOREQUALTO | Not greater than or equal | - |
NOTLESSTHAN | Not less than | - |
NOTLESSTHANOREQUALTO | Not less than or equal | - |
Text Operators
| Operator | Description | Example |
|---|---|---|
CONTAINS | Contains substring | name contains 'Corp' |
DOESNOTCONTAIN | Does not contain | name not contains 'Test' |
STARTSWITH | Starts with | name starts with 'A' |
DOESNOTSTARTWITH | Does not start with | - |
HASKEYWORDS | Full-text keyword search | memo has keywords 'urgent' |
Date Operators
| Operator | Description | Example |
|---|---|---|
ON | On specific date | date = '1/1/2024' |
NOTON | Not on date | date != '1/1/2024' |
BEFORE | Before date | date < '1/1/2024' |
AFTER | After date | date > '1/1/2024' |
ONORAFTER | On or after | date >= '1/1/2024' |
ONORBEFORE | On or before | date <= '1/1/2024' |
NOTAFTER | Not after | - |
NOTBEFORE | Not before | - |
NOTONORAFTER | Not on or after | - |
NOTONORBEFORE | Not on or before | - |
WITHIN | Within date range | date within lastmonth |
NOTWITHIN | Not within range | - |
List/Select Operators
| Operator | Description | Example |
|---|---|---|
ANYOF | Match any value | status anyof ['A', 'B'] |
NONEOF | Match none | status noneof ['C', 'D'] |
ALLOF | Match all values | - |
ANY | Any value (not empty) | - |
Operators by Field Type
Text Fields
CONTAINS,DOESNOTCONTAINSTARTSWITH,DOESNOTSTARTWITHEQUALTO,NOTEQUALTO,IS,ISNOTISEMPTY,ISNOTEMPTYHASKEYWORDS
Numeric Fields
EQUALTO,NOTEQUALTOGREATERTHAN,GREATERTHANOREQUALTOLESSTHAN,LESSTHANOREQUALTOBETWEEN,NOTBETWEENISEMPTY,ISNOTEMPTY
Date Fields
ON,NOTONBEFORE,AFTERONORAFTER,ONORBEFOREWITHIN,NOTWITHINISEMPTY,ISNOTEMPTY
Select/List Fields
ANYOF,NONEOFIS,ISNOT(single value)
Checkbox Fields
ISwith 'T' or 'F'
Search Summary Types
Use search.Summary for grouped/summarized searches.
| Summary | Description | Example Use |
|---|---|---|
GROUP | Group by field | Group by customer |
COUNT | Count records | Count orders per customer |
SUM | Sum values | Total amount by customer |
AVG | Average values | Average order value |
MIN | Minimum value | Earliest date |
MAX | Maximum value | Latest date, highest amount |
Using Summary Types
var salesSearch = search.create({
type: search.Type.TRANSACTION,
filters: [
['type', 'anyof', 'SalesOrd'],
'AND',
['mainline', 'is', 'T']
],
columns: [
search.createColumn({
name: 'entity',
summary: search.Summary.GROUP
}),
search.createColumn({
name: 'internalid',
summary: search.Summary.COUNT
}),
search.createColumn({
name: 'amount',
summary: search.Summary.SUM
})
]
});
Usage Examples
Basic Filter Examples
// Text contains
['companyname', 'contains', 'Corp']
// Numeric comparison
['amount', 'greaterthan', 1000]
// Date range
['trandate', 'within', 'lastmonth']
// Select field (use anyof)
['status', 'anyof', 'SalesOrd:B', 'SalesOrd:D']
// Checkbox (use is with T/F)
['mainline', 'is', 'T']
// Empty check
['email', 'isnotempty', '']
Using search.createFilter
var myFilter = search.createFilter({
name: 'amount',
operator: search.Operator.GREATERTHAN,
values: 1000
});
var mySearch = search.create({
type: search.Type.INVOICE,
filters: [myFilter]
});
Complex Filter Expressions
var transactionSearch = search.create({
type: search.Type.TRANSACTION,
filters: [
['type', 'anyof', 'SalesOrd'],
'AND',
['mainline', 'is', 'T'],
'AND',
[
['status', 'anyof', 'SalesOrd:B'],
'OR',
['status', 'anyof', 'SalesOrd:D']
],
'AND',
['trandate', 'within', 'thismonth']
]
});
Getting Summarized Values
salesSearch.run().each(function(result) {
var customer = result.getValue({
name: 'entity',
summary: search.Summary.GROUP
});
var orderCount = result.getValue({
name: 'internalid',
summary: search.Summary.COUNT
});
var totalAmount = result.getValue({
name: 'amount',
summary: search.Summary.SUM
});
log.debug('Customer: ' + customer,
'Orders: ' + orderCount + ', Total: ' + totalAmount);
return true;
});
Common Mistakes
Select Fields Must Use ANYOF
// Wrong - IS doesn't work for select fields
['salesrep', 'is', 123]
// Correct - Use ANYOF
['salesrep', 'anyof', 123]
Empty String for ISEMPTY/ISNOTEMPTY
// Correct - Empty string as value
['email', 'isnotempty', '']
// Also correct - Empty array
['email', 'isnotempty', []]
Checkbox Values
// Correct - Use 'T' or 'F' strings
['mainline', 'is', 'T']
// Wrong - Don't use boolean
['mainline', 'is', true]
Summary Parameter Must Match
// If column was created with SUM summary...
search.createColumn({
name: 'amount',
summary: search.Summary.SUM
});
// ...getValue must also include summary
result.getValue({
name: 'amount',
summary: search.Summary.SUM // Must match!
});