This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
entitySelection.first( )
|
entitySelection.first () -> Result | ||||||||
Parameter | Type | Description | ||||||
Result | Entity, Null |
![]() |
Reference to the first entity of the entity selection | |||||
The entitySelection.first( ) method returns a reference to the entity in the first position of the entity selection.
The result of this method is similar to:
$entity:=$entitySel[0]
There is, however, a difference between both statements when the selection is empty:
C_OBJECT($entitySel;$entity)
$entitySel:=ds.Emp.query("lastName = :1";"Nonexistentname") //no matching entity
//entity selection is then empty
$entity:=$entitySel.first() //returns Null
$entity:=$entitySel[0] //generates an error
C_OBJECT($entitySelection;$entity)
$entitySelection:=ds.Emp.query("salary > :1";100000)
If($entitySelection.length#0)
$entity:=$entitySelection.first()
End if
entity.first( )
entitySelection.last( )
entitySelection[index]
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)