This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
This
|
This -> Function result | ||||||||
Parameter | Type | Description | ||||||
Function result | Object |
![]() |
Current element or object | |||||
The This command returns a reference to the currently processed object.
The command is designed to be used in the following contexts:
In any other context, the command returns Null.
Within supported contexts, you will access object/collection element properties or entity attributes through This.<propertyPath>. For example, This.name or This.employer.lastName are valid pathes to object, element or entity properties.
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:
Case of
:(Form event code=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:
You want to use a project method as a formula encapsulated in an object:
C_OBJECT($person)
$person:=New object
$person.firstName:="John"
$person.lastName:="Smith"
$person.greeting:=Formula(Greeting)
$g:=$person.greeting("hello") // returns "hello John Smith"
$g:=$person.greeting("hi") // returns "hi John Smith"
With the Greeting project method:
C_TEXT($0;$1)
$0:=$1+" "+This.firstName+" "+This.lastName
Product: 4D
Theme: Language
Number:
1470
Created: 4D v17
Modified: 4D v17 R3
4D Language Reference ( 4D v20 R7)