workbook.createSort(options)

Note:

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

Method Description

Creates a sort, which includes indicators for sorting in ascending order, case sensitivity, sort locale, and whether nulls should be placed last.

Returns

workbook.Sort

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

boolean

optional

Indicator for sorting in ascending order. If set to false, sorting is done in descending order. The default value is true (sort in ascending order).

options.caseSensitive

boolean

optional

Indicator that the sort should consider case sensitivity.

options.locale

query.SortLocale

optional

The option for locale specific sorting.

options.nullsLast

boolean

optional

Indicator that the sort should place null items last. The default of this parameter is the value of the ascending parameter (for example, if options.ascending is set to false, the default for this parameter will be false).

Errors

Error Code

Thrown If

INVALID_SORT_LOCALE

The value specified for the options.locale parameter is invalid. Set this parameter value using query.SortLocale.

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 a default Sort
var mySort = workbook.createSort({});

// Create a custom descending Sort
var mySort = workbook.createSort({
    ascending: false,
    caseSensitive: true,
    nullsLast: true,
    locale: query.SortLocale.US_EN
});
...
// Add additional code 

          

Related Topics

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

General Notices