Column.setWhenOrderedBy(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

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 MIN or MAX as the summary type on a search column with the Result.getValue(options) method.

Returns

search.Column

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/search Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.name

string

Required

The name of the search column for which the minimal or maximal value should be found.

options.join

string

Required

The join id for the search column.

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/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 

        

Related Topics

search.Column
N/search Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices