Query.createSort(options)
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:
Note:
This method is a shortcut for the chained Query.root and Component.createSort(options): |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2018.1 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
required |
The query result column that you want to sort by. This value sets the Sort.column property. |
|
|
boolean |
optional |
Whether the sort direction is ascending. This value sets the Sort.ascending property. The default value of this property is |
|
boolean |
optional |
Whether the sort is case sensitive. This value sets the Sort.caseSensitive property. If a sort is case sensitive (and the sort direction is ascending), rows with column values that start with uppercase letters are listed before rows with column values that start with lowercase letters. If a sort is not case sensitive, uppercase and lowercase letters are treated the same. For example, the following list of items is sorted using a case-sensitive sort with a sort direction of ascending:
Here is the same list of items sorted using a regular (not case-sensitive) sort with a sort direction of ascending:
The default value of this property is |
|
string |
optional |
The locale to use for the sort. This value sets the Sort.locale property. A locale represents a combination of language and region, and it can affect how certain values (such as strings) are sorted. For example, languages that share the same alphabet may sort characters differently. Use this property to ensure that query results are sorted using locale-specific rules. Use the appropriate query.SortLocale enum value to pass in your argument. This enum holds all the supported values for this parameter. |
|
boolean |
optional |
Whether query results with null values are listed at the end of the query results. This value sets the Sort.nullsLast property. The default value of this property is the value of the |
Syntax
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 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