Modules

filter

 

Objects/Functions

module (N/query)

SuiteScript 2.0

Component.createColumn(options)

{Component}.createColumn({fieldId: {string},formula: {string},type: {string},aggregate: {string},groupBy: {boolean},label: ${7:string},context: {name: ${9:string},params: {0:Object},params: {1:number},})

N/query Module
Component.createColumn()
Method Description: Creates a query result column based on the query.Component object. The query.Column object is the equivalent of the search.Column object in the N/search Module. The query.Column object describes the field types (columns) that are displayed from the query results. To create columns: Use Component.createColumn(options) to create columns on the join relationships created with Query.autoJoin(options) and Component.autoJoin(options). Use this method in one of two ways: Pass in an argument for the parameter options.fieldId. Pass in an argument for the parameter options.formula. If you use this option, you can also use the optional parameter options.type. If needed, use Query.createColumn(options) to create columns on the initial query definition created with query.create(options). Assign all created columns as array values to Query.columns. For an example, see Syntax. When you create a column, you can specify a field context. The field context determines how field values are displayed in the column. For example, you can specify that a column should display raw data (such as internal IDs), consolidated or converted amounts (such as currency totals), or user-friendly values (such as names). You can specify a field context in two ways: Use a context from the query.FieldContext enum directly as the value of the options.context parameter. For example: This example is the simplest way to specify a field context that does not accept additional parameters. Because the options.context parameter is an Object, this example is equivalent to the following: Use a context from the query.FieldContext enum as the value of the options.context.name parameter, and specify additional parameters using the options.context.params parameter. For example: In this release, only the query.FieldContext.CONVERTED context uses additional parameters. The supported parameters are currencyId and date. For the date parameter, you can pass a JavaScript Date object or query.RelativeDate object.
Returns: query.Column
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.Component
Sibling Object Members: Component Object Members
Since: 2018.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=Component.createColumn(options)

Example:

// Code Example 1
myTransactionLine.createColumn({
fieldId: 'netamount',
context: query.FieldContext.CURRENCY_CONSOLIDATED
});

// Code Example 2
myTransactionLine.createColumn({
fieldId: 'netamount',
context: {
name: query.FieldContext.CURRENCY_CONSOLIDATED
}
});

// Code Example 3
myTransactionLine.createColumn({
fieldId: 'netamount',
context: {
name: query.FieldContext.CONVERTED,
params: {
currencyId: 4,
date: new Date('2019/01/01')
}
}
});

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

var mySalesRepJoin = myCustomerQuery.join({
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_1510784945.html