Skip to main content

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

OperatorDescriptionField Types
EQUALTOExact matchAll
NOTEQUALTONot equalAll
ISExact match (alias)All
ISNOTNot equal (alias)All
ISEMPTYField is empty/nullAll
ISNOTEMPTYField has valueAll

Numeric Operators

OperatorDescriptionExample
GREATERTHANGreater thanamount > 100
GREATERTHANOREQUALTOGreater than or equalamount >= 100
LESSTHANLess thanamount < 100
LESSTHANOREQUALTOLess than or equalamount <= 100
BETWEENWithin rangeamount BETWEEN 100 AND 500
NOTBETWEENOutside rangeamount NOT BETWEEN 100 AND 500
NOTGREATERTHANNot greater than-
NOTGREATERTHANOREQUALTONot greater than or equal-
NOTLESSTHANNot less than-
NOTLESSTHANOREQUALTONot less than or equal-

Text Operators

OperatorDescriptionExample
CONTAINSContains substringname contains 'Corp'
DOESNOTCONTAINDoes not containname not contains 'Test'
STARTSWITHStarts withname starts with 'A'
DOESNOTSTARTWITHDoes not start with-
HASKEYWORDSFull-text keyword searchmemo has keywords 'urgent'

Date Operators

OperatorDescriptionExample
ONOn specific datedate = '1/1/2024'
NOTONNot on datedate != '1/1/2024'
BEFOREBefore datedate < '1/1/2024'
AFTERAfter datedate > '1/1/2024'
ONORAFTEROn or afterdate >= '1/1/2024'
ONORBEFOREOn or beforedate <= '1/1/2024'
NOTAFTERNot after-
NOTBEFORENot before-
NOTONORAFTERNot on or after-
NOTONORBEFORENot on or before-
WITHINWithin date rangedate within lastmonth
NOTWITHINNot within range-

List/Select Operators

OperatorDescriptionExample
ANYOFMatch any valuestatus anyof ['A', 'B']
NONEOFMatch nonestatus noneof ['C', 'D']
ALLOFMatch all values-
ANYAny value (not empty)-

Operators by Field Type

Text Fields

  • CONTAINS, DOESNOTCONTAIN
  • STARTSWITH, DOESNOTSTARTWITH
  • EQUALTO, NOTEQUALTO, IS, ISNOT
  • ISEMPTY, ISNOTEMPTY
  • HASKEYWORDS

Numeric Fields

  • EQUALTO, NOTEQUALTO
  • GREATERTHAN, GREATERTHANOREQUALTO
  • LESSTHAN, LESSTHANOREQUALTO
  • BETWEEN, NOTBETWEEN
  • ISEMPTY, ISNOTEMPTY

Date Fields

  • ON, NOTON
  • BEFORE, AFTER
  • ONORAFTER, ONORBEFORE
  • WITHIN, NOTWITHIN
  • ISEMPTY, ISNOTEMPTY

Select/List Fields

  • ANYOF, NONEOF
  • IS, ISNOT (single value)

Checkbox Fields

  • IS with 'T' or 'F'

Search Summary Types

Use search.Summary for grouped/summarized searches.

SummaryDescriptionExample Use
GROUPGroup by fieldGroup by customer
COUNTCount recordsCount orders per customer
SUMSum valuesTotal amount by customer
AVGAverage valuesAverage order value
MINMinimum valueEarliest date
MAXMaximum valueLatest 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!
});