Column.setWhenOrderedBy(options)
Method Description |
Returns the search column for which the minimal or maximal value should be found when returning the search.Column value. For example, can be set to find the most recent or earliest date, or the largest or smallest amount for a record, and then the search.Column value for that record is returned.
Note:
You can only use this method if you use |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
string |
required |
The name of the search column for which the minimal or maximal value should be found. |
|
string |
required |
The join id for the search column. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/search Module Script Samples.
// Add additional code
...
// Execute a customer search that returns the amount of the most recent sales order per customer
var filters = [];
var columns = [];
filters[0] = search.createFilter({
name: 'recordtype',
join: 'transaction',
operator: search.Operator.IS,
values: 'salesorder'
});
filters[1] = search.createFilter({
name: 'mainline',
join: 'transaction',
operator: search.Operator.IS,
values: true
});
columns[0] = search.createColumn({
name: 'entityid',
summary: search.Summary.GROUP
});
columns[1] = search.createColumn({
name: 'totalamount',
join: 'transaction',
summary: search.Summary.MAX
});
columns[1].setWhenOrderedBy({
name: 'trandate',
join: 'transaction'
});
var mySearch = search.create({
type: 'customer',
filters: filters,
columns: columns
});
var resultsArray = mySearch.run().getRange({
start: 0,
end: 100
});
...
// Add additional code