Skip to main content
Version: Next

Create entity selection

Create entity selection ( dsTable : Table { ; settings : Object } ) : 4D.EntitySelection

ParameterTypeDescription
dsTableTable→Table in the 4D database whose current selection will be used to build the entity selection
settingsObject→Build option: context
Function result4D.EntitySelection←Entity selection matching the dataclass related to the given table
History
ReleaseChanges
17 R5Modified
17Created

Description​

The Create entity selection command builds and returns a new, alterable entity selection related to the dataclass matching the given dsTable, according to the current selection of this table.

If the current selection is sorted, an ordered entity selection is created (the order of the current selection is kept). If the current selection is unsorted, an unordered entity selection is created.

If the dsTable is not exposed in ds, an error is returned. This command cannot be used with a Remote datastore.

In the optional settings parameter, you can pass an object containing the following property:

PropertyTypeDescription
contextTextLabel for the optimization context applied to the entity selection.
info

For performance reasons, in 4D single-user and 4D Server, the returned entity selection is directly connected to the current selection of dsTable (it is not a copy). Until the current selection is replaced, changes made to one are reflected in the other. For example, REDUCE SELECTION shortens the entity selection, and .add() on the entity selection adds the entity to the current selection. To get an independent entity selection, call .copy() on the result:

$es:=Create entity selection([Employee]).copy()

Example​

var $employees : cs.EmployeeSelection
ALL RECORDS([Employee])
$employees:=Create entity selection([Employee])
// The $employees entity selection now contains a set of reference
// on all entities related to the Employee dataclass

See also​

USE ENTITY SELECTION
dataClass.newSelection()

Properties​

Command number1512
Thread safeyes