This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
entity.fromObject( )
|
entity.fromObject ( object ) | ||||||||
Parameter | Type | Description | ||||||
object | Object |
![]() |
Object from which to fill the entity | |||||
The entity.fromObject( ) method fills an entity with the object content.
Note: This method modifies the original entity.
The mapping between the object and the entity is done on the attribute names:
object can handle a related entity under the following conditions:
With the following $o object:
{ "firstName": "Mary", "lastName": "Smith", "salary": 36500, "birthDate": "1958-10-27T00:00:00.000Z", "woman": true, "managerID": 411,// relatedEntity given with PK "employerID": 20 // relatedEntity given with PK }
The following code will create an entity with manager and employer related entities.
C_OBJECT($o)
$entity:=ds.Emp.new()
$entity.fromObject($o)
$entity.save()
You could also use a related entity given as an object:
{ "firstName": "Marie", "lastName": "Lechat", "salary": 68400, "birthDate": "1971-09-03T00:00:00.000Z", "woman": false, "employer": {// relatedEntity given as an object "__KEY": "21" }, "manager": {// relatedEntity given as an object "__KEY": "411" } }
Product: 4D
Theme: ORDA - Entity
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)