workbook.ExpressionType

Note:

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

Note:

JavaScript does not include an enumeration type. The SuiteScript 2.0 documentation uses the term enumeration (or enum) to describe a plain JavaScript object with a flat, map-like structure. In this object, each key points to a read-only string value.

Enum Description

Holds string values for expression types.

Use these values for the options.functionId parameter when creating an expression using workbook.createExpression(options). Each expression type uses a set of parameters, which you specify using the options.parameters parameter of workbook.createExpression(options).

Make sure that you use the exact parameter names that are supported for each expression type. For example, if you create an EQUALS expression, the supported parameters are operand1 and operand2. You can specify these parameters as the value of the options.parameters parameter of workbook.createExpression(options):

                    parameters: {
    operand1: <first value to test>,
    operand2: <second value to test>
} 

                  

Module

N/workbook Module

Sibling Module Members

N/workbook Module Members

Since

2020.2

Values

Value

Supported Parameters

Description

AND

expressions

Returns true if all specified expressions evaluate to true.

The specified expressions must be boolean expressions.

ANY_OF

expression

set

Returns true if expression is equal to one of the expressions in set.

BETWEEN

expression

min

max

Returns true if expression is between min and max (inclusive).

The specified expressions must be numeric expressions.

CHILD_OF

child

parent

hierarchy

Returns true if child is a child of parent, and they both belong to the hierarchy hierarchy.

COMPARE

comparisonType

operand1

operand2

Returns true if operand1 and operand2 have a comparisonType relationship (such as equal to, greater than, less than, and so on).

You can specify the following relationships (as strings for comparisonType):

  • EQUAL

  • GREATER

  • GREATER_OR_EQUAL

  • LESS

  • LESS_OR_EQUAL

CONSTANT

type

value

Creates a constant with a type of type and a value of value.

The type can often be inferred automatically, but not in all cases. For example, there is no way to distinguish between decimal values and integer values, so in this case, you must specify the type.

CURRENCY_CONVERSION

expression

targetCurrency (optional)

date (optional)

Applies currency conversion on a currency expression.

The exchange rate is determined by the values for source currency, target currency, and date. If the target currency is not specified, the expression uses the currency of the user’s subsidiary. If the date is not specified, the expression uses the exchange rate for the current date.

DATASET_COLUMN

DATE_RANGE_SELECTOR_ID

expression

anchor (optional)

Converts a relative date expression (as a query.RelativeDateRange value) to its corresponding date range expression.

The anchor lets you specify the starting point for the relative date. If an anchor is not specified, the current date is used.

DATE_SELECTOR_ID

expression

anchor

startExpected

Converts a relative date expression (as a query.RelativeDateRange value) to its corresponding date expression.

The anchor lets you specify the starting point for the relative date. If an anchor is not specified, the current date is used.

startExpected is a boolean expression. If true, the start date of the relative date is returned. If false, the end date of the relative date is returned.

DATE_TIME_PROPERTY

dateTime

property

hierarchy

Returns a property from the specified date/time expression.

For property, use a value from the workbook.DateTimeProperty enum.

DIVIDE

operand1

operand2

Returns operand1 divided by operand2.

Both operands must be numeric expressions.

EQUALS

operand1

operand2

Returns true if operand1 and operand2 are equal.

FIELD

type

fieldId

datasetId

References a field of a certain type in the datasetId dataset.

Do not create the fieldId expression yourself. Instead, use Dataset.getExpressionFromColumn(options).

HIERARCHY

hierarchy

expression

Enables hierarchy for an expression.

hierarchy is an expression that resolves to a record. expression is the hierarchy expression.

Typically, the hierarchy value is defaulthierarchy.

HIERARCHY_TO_TEXT

hierarchy

levelToText

delimiter

Converts individual values of a hierarchy to a single string value using concatenation and the specified delimiter character.

For example, if a hierarchy includes the values L1, L1.1, and L1.1.1 and you specify a delimiter character of /, the converted value is L1/L1.1/L1.1.1.

Typically, the hierarchy value is defaulthierarchy.

IF

IN_RANGE

value

range

Returns true if value is inside range.

range can be created using the DATE_RANGE_SELECTOR_ID function.

IS_NULL

expression

Returns true if expression evaluates to NULL.

LAMBDA

None

Returns the value of the current expression.

You can use this function only as an argument in another expression. For example, the HIERARCHY_TO_TEXT expression type uses this type to transform a hierarchy level value to a string.

MEASURE_VALUE

measure

Returns an expression that holds the value of the measure measure.

MINUS

operand1

operand2

Returns operand1 minus operand2.

MULTIPLY

operand1

operand2

Returns operand1 multiplied by operand2.

NOT

expression

Returns true if expression evaluates to false.

OR

expressions

Returns true if at least one of the specified expressions evaluates to true.

The specified expressions must be boolean expressions.

PLUS

operand1

operand2

Returns operand1 plus operand2.

RECORD_DISPLAY_VALUE

record

Returns a display value from the specified record.

The returned value and value type are based on the type of record you specify.

RECORD_KEY

record

Returns the record key (sometimes called the internal ID) of the specified record.

SIMPLE_CONSOLIDATE

expression

Consolidates a currency expression based on the user’s subsidiary and the current accounting period.

TRANSLATE

key

collection

Returns the key string from the collection translation collection.

TRUNCATE_DATE_TIME

dateTime

unit

Returns a date/time value, and if any fields have a value that is smaller than the specified unit of time, these fields are set to zero.

For example, if you use this expression type with a unit of minutes, the second-of-minute and nano-of-second fields are set to zero.

You can specify the following units of time:

  • hours

  • minutes

  • seconds

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/workbook Module Script Samples.

            // Add additional code
...
var myExpression = workbook.createExpression({
    functionId: workbook.ExpressionType.EQUALS,
    parameters: {
        operand1: dataset.getExpressionFromColumn({
            alias: 'salary'
        }),
        operand2: workbook.createConstant(10000)
    }
});
// Add additional code 

          

Related Topics

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

General Notices