4D v17.4

This

Home

 
4D v17.4
This

This 


 

This -> Function result 
Parameter Type   Description
Function result  Object in The current element

The This command returns a reference to the currently processed object.

The command is designed to be used in the following context:

  • a list box associated to a collection or an entity selection,
  • during the On Display Detail event or the On Data Change event.

In this specific context, the command returns a reference to the collection element or entity accessed by the list box to display the current row. In any other contexts, the command returns Null.

You can access collection element properties or entity attributes through This.<propertyPath>. For example, This.name or This.employer.lastName are valid pathes to element or entity properties.

Note: If you use a collection of scalar values, 4D creates an object for each element with a single value property. Thus, the element value is available through the This.value expression.

A collection of objects, each with this structure:

{  
"ID": 1234
"name": "Xavier",  
"revenues": 47300,  
"employees": [  
             "Allan",  
             "Bob", 
             "Charlie"  
            ] 
},{  
"ID": 2563
"name": "Carla",  
"revenues": 55000,  
"isFemale": true
"employees": [  
             "Igor",  
             "Jane"  
            ] 
},...
 

In the list box, each column refers to one of the properties of the object, either directly (This.name), indirectly (This.employees.length), or through an expression (getPicture) in which can be used directly. The list box looks like:

The GetPicture project method is automatically executed during the On display detail event:

  //GetPicture Method
 C_PICTURE($0)
 If(This.isFemale)
    $0:=Form.genericFemaleImage
 Else
    $0:=Form.genericMaleImage
 End if

Once the form is executed, you can see the result:

You want to display entities from the following structure in a list box:

You build a list box of the "Collection or entity selection" type with the following definition:

Note that:

  • This.ID, This.Title and This.Date directly refers to the corresponding attributes in the ds.Event dataclass.
  • This.meetings is a related attribute (based upon the One To Many relation name) that returns an entity selection of the ds.Meeting dataclass.
  • Form.eventList is the entity selection that is attached to the list box. The initialization code can be put in the on load form event:
     Case of
        :(Form event=On Load)
           Form.eventList:=ds.Event.all() //returns an entity selection with all entities
     End case

Once the form is executed, the list box is automatically filled with the entity selection:



See also 

Self

 
PROPERTIES 

Product: 4D
Theme: Language
Number: 1470

This command can be run in preemptive processes

 
HISTORY 

New
Created: 4D v17

 
ARTICLE USAGE

4D Language Reference ( 4D v17)
4D Language Reference ( 4D v17.1)
4D Language Reference ( 4D v17.2)
4D Language Reference ( 4D v17.3)
4D Language Reference ( 4D v17.4)