Modules

filter

 

Objects/Functions

module (N/query)

SuiteScript 2.0

Query.createCondition(options)

{Query}.createCondition({fieldId: {string},operator: {string*},values: {string[] | number[] | boolean[] | Date[] | query.RelativeDate[] | query.Period[]},formula: {string},type: {string},aggregate: ${7:string}})

N/query Module
Query.createCondition()
Method Description: Creates a condition (query filter) based on the query.Query object. A condition narrows the query results. The query.Condition object acts in the same capacity as the search.Filter object in the N/search Module. The primary difference is that query.Condition objects can contain other query.Condition objects. To create conditions: Use Query.createCondition(options) to create conditions on the initial query definition created with query.create(options). Use this method in one of two ways: Pass in arguments for the parameters options.fieldId, options.operator, and options.values. The combination of these arguments translates to (for example, ‘city’ equals ‘Boston’). Pass in an argument for the parameter options.formula. If you use this option, you can also use the optional parameter options.type. If needed, use Component.createCondition(options) to create conditions on the join relationships created with Query.autoJoin(options) and Component.autoJoin(options). If you have multiple conditions, use them to create a new nested condition with the methods Query.and(conditions), Query.or(conditions), and Query.not(condition). Assign your simple or nested condition to Query.condition. For an example, see Syntax. This method is a shortcut for the chained Query.root and Component.createCondition(options): Query.root.createCondition(options). The Query.root property references the root component, which is a query.Component object.
Returns: query.Condition
Supported Script Types: Client and server scripts For more information, see SuiteScript 2.0 Script Types.
Governance: None
Module: N/query Module
Parent Object: query.Query
Sibling Object Members: Query Object Members
Since: 2018.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=Query.createCondition(options)

Example:

// Code Example 1
// Add additional code
//...
var myCustomerQuery = query.create({
type: query.Type.CUSTOMER
});

var mySalesRepJoin = myCustomerQuery.autoJoin({
fieldId: 'salesrep'
});

var myLocationJoin = mySalesRepJoin.autoJoin({
fieldId: 'location'
});

var firstCondition = myCustomerQuery.createCondition({
fieldId: 'id',
operator: query.Operator.EQUAL,
values: 107
});
var secondCondition = myCustomerQuery.createCondition({
fieldId: 'id',
operator: query.Operator.EQUAL,
values: 2647
});
var thirdCondition = mySalesRepJoin.createCondition({
fieldId: 'email',
operator: query.Operator.START_WITH_NOT,
values: 'foo'
});

myCustomerQuery.condition = myCustomerQuery.and(
thirdCondition, myCustomerQuery.not(
myCustomerQuery.or(firstCondition, secondCondition)
)
);

var resultSet = myCustomerQuery.run();
//...
// Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_1510780329.html