This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
entity.indexOf( )

entity.indexOf( ) 


 

entity.indexOf ( {entitySelection} ) -> Result 
Parameter Type   Description
entitySelection  EntitySelection in Position of the entity is given according to this entity selection
Result  Longint in Position of the entity in an entity selection

The entity.indexOf( ) method returns the position of the entity in an entity selection.

By default if the entitySelection parameter is omitted, the method returns the entity's position within its own entity selection. Otherwise, it returns the position of the entity within the specified entitySelection.

The resulting value is included between 0 and the length of the entity selection -1.

  • If the entity does not have an entity selection or does not belong to entitySelection, the method returns -1.
  • If entitySelection is Null or does not belong to the same dataclass as the entity, an error is raised.

Example  

 C_OBJECT($employees;$employee)
 $employees:=ds.Employee.query("lastName = :1";"H@") //This entity selection contains 3 entities
 $employee:=$employees[1] //This entity belongs to an entity selection
 ALERT("The index of the entity in its own entity selection is "+String($employee.indexOf())) //1
 
 C_OBJECT($employee)
 $employee:=ds.Employee.get(725) //This entity does not belong to an entity selection
 ALERT("The index of the entity is "+String($employee.indexOf())) // -1



See also 

entitySelection.contains( )

 
PROPERTIES 

Product: 4D
Theme: ORDA - Entity

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17

 
ARTICLE USAGE

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)