Create entity selection
Create entity selection ( dsTable : Table { ; settings : Object } ) : 4D.EntitySelection
| Parameter | Type | Description | |
|---|---|---|---|
| dsTable | Table | → | Table in the 4D database whose current selection will be used to build the entity selection |
| settings | Object | → | Build option: context |
| Function result | 4D.EntitySelection | ← | Entity selection matching the dataclass related to the given table |
History
| Release | Changes |
|---|---|
| 17 R5 | Modified |
| 17 | Created |
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:
| Property | Type | Description |
|---|---|---|
| context | Text | Label for the optimization context applied to the entity selection. |
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 SELECTIONdataClass.newSelection()
Properties
| Command number | 1512 |
| Thread safe | yes |