Modules

filter

 

Objects/Functions

module (N/query)

SuiteScript 2.0

Query.createSort(options)

{Query}.createSort({column: {query.Column*},ascending: {boolean},caseSensitive: {boolean},locale: {string},nullsLast: {boolean}})

N/query Module
Query.createSort()
Method Description: Creates a sort based on the query.Query object. The query.Sort object describes a sort that is placed on a particular query result column. To create a sort: Use Search.createSort(options) to create a sort based on the initial query definition created with query.create(options). Use Component.createSort(options) to create a sort based on a join relationship created with Query.autoJoin(options) or Component.autoJoin(options). Assign all created sorts as array values to Query.sort. For an example, see Syntax. This method is a shortcut for the chained Query.root and Component.createSort(options): Query.root.createSort(options). The Query.root property references the root component, which is a query.Component object.
Returns: query.Sort
Supported Script Types: Client and server scripts For more information, see SuiteScript 2.0 Script Types.
Governance: None
Module: N/query Module
Parent Object: query.Query
Sibling Object Members: Query Object Members
Since: 2018.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=Query.createSort(options)

Example:

// Code Example 1
// Add additional code
//...
var myCustomerQuery = query.create({
type: query.Type.CUSTOMER
});

var mySalesRepJoin = myCustomerQuery.autoJoin({
fieldId: 'salesrep'
});

myCustomerQuery.columns = [
myCustomerQuery.createColumn({
fieldId: 'entityid'
}),
myCustomerQuery.createColumn({
fieldId: 'id'
}),
mySalesRepJoin.createColumn({
fieldId: 'entityid'
}),
mySalesRepJoin.createColumn({
fieldId: 'email'
}),
mySalesRepJoin.createColumn({
fieldId: 'hiredate'
})
];

myCustomerQuery.sort = [
myCustomerQuery.createSort({
column: myCustomerQuery.columns[1]
}),
mySalesRepJoin.createSort({
column: mySalesRepJoin.columns[0],
ascending: false
})
];

var resultSet = myCustomerQuery.run();
//...
// Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_1510780402.html