Skip to main content
Version: 11.2

UDB Cols object

note

This article is about the Cols object in the UDB object model. This model is for data exchange between USoft web UIs and Rules Engines. This model is built around the udb, DataSourceContainer, Rowset, Rows, and Cols object types. See also UDB events.

A Cols object, defined by the UdbCols class, contains a collection of columns (UdbColumn instances).

note

In USoft 10, column value functions (like .val()) and column meta-information functions (like .name() or .isMandatory()) were exposed on two separate objects, Cols and ColsMeta, reached via $.udb() and $.udbMeta() respectively. In USoft 11, $.udbMeta() is obsolete and both kinds of functions are exposed together on the single UdbCols class.

Syntax

$.udb( *ds* ).cols( [columns] )
$.udb( *ds* ).rows( [rowRef1], [rowRef2] ).cols( [columns] )
$.udb( *ds* ).rowSet( *rowSet* ).rows( [rowRef1], [rowRef2] ).cols( [columns] )

The required ds is a data source selector.

The optional rowSet parameter is a rowset identifier. If the .rowSet() clause is omitted, then .rowSet('current') is assumed.

The optional rowRef1, rowRef2 are row selectors. If omitted, only the column meta data can be accessed. For actions that read or write an actual value, such as .val(), a row selector identifying a specific record is required.

The optional columns is a column selector. If omitted, all columns in scope are selected.

Column selectors

Columns is a column selector: an expression whereby you identify a single column or multiple columns in a data source. You can identify a single column by:

  • A name string, e.g. 'EMPNO'.
  • A column ID, which is a combination of a '$' symbol and a generated integer, e.g. '$26'.
  • If the column is in an embedded data source: the name of that embedded data source, followed by a forward slash (/), followed by a column name or column ID, e.g. 'Embedded DEPARTMENT/NAME'.

You can also select multiple columns by passing an array of any of the above.

In general, it is recommended to refer to columns just by their name (or embedded path, in case of embedded data source columns). This is the best readable format, and it is not subject to being changed like the ID's, which may change with any changes to your data sources in the Web Designer.

Example

let empNo = $.udb('EMP').rows('current').cols('EMPNO');

console.log(empNo.val());

Example output:
'11056'