workbook.createConstant(options)

Note:

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

Method Description

Creates a constant expression.

Returns

workbook.Expression

Supported Script Types

Server scripts

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

Governance

None

Module

N/workbook Module

Sibling Module Members

N/workbook Module Members

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.constant

string | number | boolean | Date

required

The ID of the function to use.

options.type

workbook.ConstantType

optional

The type of constant.

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 myBooleanConstant = workbook.createConstant({
    constant: true,
    type: workbook.ConstantType.BOOLEAN
});

var myCurrencyConstant = workbook.createConstant({
    constant: 10,
    type: workbook.ConstantType.CURRENCY
});

var myDateConstant = workbook.createConstant({
    constant: newDate(),
    type: workbook.ConstantType.DATE
});

var myDateTimeConstant = workbook.createConstant({
    constant: newDate(),
    type: workbook.ConstantType.DATE_TIME
});

var myDurationConstant = workbook.createConstant({
    constant: 15,
    type: workbook.ConstantType.DURATION
});

var myNumberConstant = workbook.createConstant({
    constant: 77,
    type: workbook.ConstantType.NUMBER
});

var myTextConstant = workbook.createConstant({
    constant: 'Sample Text',
    type: workbook.ConstantType.TEXT
});
...
// Add additional code 

          

Related Topics

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

General Notices