This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
entity.touched( )
|
entity.touched () -> Result | ||||||||
Parameter | Type | Description | ||||||
Result | Boolean |
![]() |
True if at least one entity attribute has been modified and not yet saved, else False | |||||
The entity.touched( ) method tests whether or not an entity attribute has been modified since the entity was loaded into memory or saved.
If an attribute has been modified or calculated, the method returns true, else it returns false. You can use this method to determine if you need to save the entity.
This method returns false for a new entity that has just been created (with dataClass.new( )). Note however that if you use a method which calculates an attribute of the entity, the entity.touched( ) method will then return true. For example, if you call entity.getKey( ) to calculate the primary key, the entity.touched( ) method returns true.
In this example, we check to see if it is necessary to save the entity:
C_OBJECT($emp)
$emp:=ds.Employee.get(672)
$emp.firstName:=$emp.firstName // Even if updated with the same value, the attribute is marked as touched
If($emp.touched()) //if at least one of the attributes has been changed
$emp.save()
End if // otherwise, no need to save the entity
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)