dataset.createCondition(options)

Note:

The content in this help topic applies to SuiteScript 2.x.

Method Description

Creates a dataset condition (criteria). A condition is applied to a dataset column and includes an operator.

For more information about criteria used in datasets in SuiteAnalytics, see Dataset Criteria Filters.

Returns

dataset.Condition

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/dataset Module

Sibling Module Members

N/dataset Module Members

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.children

dataset.Condition[]

optional

The child conditions.

Conditions can be grouped. A group of conditions is represented as a single Condition object that combines the child conditions in the group using the AND operator. This Condition object can then be used as one of the children of a higher-level condition.

Use this parameter when the options.operator parameter is set to ‘AND’ or ‘OR’.

options.column

dataset.Column

required, unless options.children is specified

The column to apply the condition to.

For the top-level condition in a dataset (the single condition that child conditions are combined into), this property is always null. Child conditions are implicitly combined using the appropriate operator (AND, OR) to produce a single condition, so no column needs to be specified.

options.operator

string

required

The operator for the condition. For the top-level condition in a dataset (the single condition that child conditions are combined into), this property is always either AND or OR. The top-level condition can only combine child conditions using these operators, not more advanced ones (like NOT or ANY_OF).

You can use values from query.Operator. You can also use ‘AND’ or ‘OR’ when the options.children parameter is used.

options.values

Array<null|Object|number|string|boolean|Date>

optional

The values for the condition.

For the top-level condition in a dataset (the single condition that child conditions are combined into), this property is always an empty array. Child conditions are implicitly combined using the appropriate operator (AND, OR) to produce a single condition, so no values need to be specified.

Errors

Error Code

Thrown If

INVALID_OPERATOR

The options.operator parameter is invalid.

MUTUALLY_EXCLUSIVE_ARGUMENTS

Both the options.column and options.children parameters are specified.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/dataset Module Script Samples.

            // Add additional code
...
// Create a Condition without values
var myCondition = dataset.createCondition({
    column: myNameColumn,
    operator: query.Operator.EMPTY
});

// Create a Condition with values
var myCondition = dataset.createCondition({
    column: myNameColumn,
    operator: query.Operator.EQUAL,
    values: ['Smith']
});
// Create a Condition with children
var myCondition = dataset.createCondition({
    operator: query.Operator.IS,
    children: myChildCondition    // Create this with a separate call to dataset.createCondition
});
...
// Add additional code 

          

Related Topics

N/dataset Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices