This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
entitySelection[index]
|
entitySelection[index] -> Result | ||||||||
Parameter | Type | Description | ||||||
Result | Entity |
![]() |
Entity corresponding to the specified index (non assignable expression) | |||||
The entitySelection[index] notation allows you to access entities within the entity selection using the standard collection syntax: pass the position of the entity you want to get in the index parameter.
Note that the corresponding entity is reloaded from the datastore.
index can be any number between 0 and entitySelection.length-1.
Warning: entitySelection[index] is a non assignable expression, which means that it cannot be used as en editable entity reference with methods like entity.lock( ) or entity.save( ). To work with the corresponding entity, you need to assign the returned expression to an assignable expression, such as a variable. Examples:
$sel:=ds.Employee.all() //create the entity selection
//invalid statements:
$result:=$sel[0].lock() //will NOT work
$sel[0].lastName:="Smith" //will NOT work
$result:=$sel[0].save() //will NOT work
//valid code:
$entity:=$sel[0] //OK
$entity.lastName:="Smith" //OK
$entity.save() //OK
C_OBJECT($employees;$employee)
$employees:=ds.Employee.query("lastName = :1";"H@")
$employee:=$employees[2] // The 3rd entity of the $employees entity selection is reloaded from the database
Product: 4D
Theme: ORDA - EntitySelection
Created: 4D v17
4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)