4D v19

entity.indexOf( )

Home

 
4D v19
entity.indexOf( )

entity.indexOf( )  


 

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 

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)