workbook.createSortDefinition(options)

Note:

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

Method Description

Creates a sort definition. A sort definition is used to specify sorting for a pivot or pivot axis.

Returns

workbook.SortDefinition

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.selector

workbook.DimensionSelector | workbook.PathSelector

required

The selector for the sort definition.

options.sortBys

workbook.MeasureSort[]

required

The sort order for the sort definition.

Errors

Error Code

Thrown If

NO_SORT_BY_DEFINED

The value set for the options.sortBys parameter is empty.

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
...
// Create an AllSubNodesSelector SortDefinition sorted by Measure
var mySort = workbook.createSortDefinition({
    selector: workbook.createAllSubNodesSelector(),
    sortBys: [myMeasureSort]
});

// Create a DimensionSelector SortDefinition sorted by Measure
var mySort = workbook.createSortDefinition({
    selector: myDimensionSelector,
    sortBys: [myMeasureSort]
});

// Create a PathSelector SortDefinition sorted by Dimension
var mySort = workbook.createSortDefinition({
    selector: myPathSelector,
    sortBys: [myDimensionSort]
});
...
// Add additional code 

          

Related Topics

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

General Notices