query.createPeriod(options)

Method Description

Creates a query.Period object.

Returns

query.Period

Supported Script Types

Client and server scripts

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

Governance

None

Module

N/query Module

Sibling Module Members

N/query Module Members

Since

2020.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.code

string

required

The code of the period to create.

Use a value from the query.PeriodCode enum for this parameter.

options.adjustment

string

optional

The adjustment of the period to create.

Use a value from the query.PeriodAdjustment enum for this parameter. The default value is query.PeriodAdjustment.NOT_LAST.

options.type

string

optional

The type of the period to create.

Use a value from the query.PeriodType enum for this parameter. The default value is query.PeriodType.START.

Errors

Error Code

Thrown If

INVALID_PERIOD_ADJUSTMENT

The specified period adjustment is not a value from the query.PeriodAdjustment enum.

INVALID_PERIOD_CODE

The specified period code is not a value from the query.PeriodCode enum.

INVALID_PERIOD_TYPE

The specified period type is not a value from the query.PeriodType enum.

WRONG_PARAMETER_TYPE

Any of the parameters is not a string.

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

            // Add additional code
...
    var myPeriod = query.createPeriod({
        code: query.PeriodCode.LAST_PERIOD,
        adjustment: query.PeriodAdjustment.ALL,
        type: query.PeriodType.END
    });
    // myQuery is an existing query.Query object
    var myComplexCondition = myQuery.createCondition({
        fieldId: 'trandate',
        operator: query.Operator.BEFORE,
        values: [myPeriod]
    });
...
// Add additional code 

          

Related Topics

General Notices