| 4D v18entity.save( ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | 
    4D v18
 entity.save( ) 
         | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property | Type | Description | |
| success | boolean | True if the save action is successful, False otherwise. | |
| Available only if dk auto merge option is used: | |||
| autoMerged | boolean | True if an auto merge was done, False otherwise. | |
| Available only in case of error: | |||
| status(*) | number | Error code, see below | |
| statusText(*) | text | Description of the error, see below | |
| Available only in case of pessimistic lock error: | |||
| lockKindText | text | "Locked by record" | |
| lockInfo | object | Information about the lock origin | |
| task_id | number | Process id | |
| user_name | text | Session user name on the machine | |
| user4d_id | text | User name in the 4D database directory | |
| host_name | text | Machine name | |
| task_name | text | Process name | |
| client_version | text | ||
| Available only in case of serious error (serious error - can be trying to duplicate a primary key, disk full...): | |||
| errors | collection of objects | ||
| message | text | Error message | |
| componentSignature | text | Internal component signature (e.g. "dmbg" stands for the database component) | |
| errCode | number | Error code | 
(*) The following values can be returned in the status and statusText properties of Result object in case of error:
| Constant | Value | Comment | 
| dk status automerge failed | 6 | (Only if the dk auto merge option is used) The automatic merge option failed when saving the entity. Associated statusText: "Auto merge failed" | 
| dk status entity does not exist anymore | 5 | The entity no longer exists in the data. This error can occur in the following cases: 
 Associated statusText: "Entity does not exist anymore" | 
| dk status locked | 3 | The entity is locked by a pessimistic lock. Associated statusText: "Already locked" | 
| dk status serious error | 4 | A serious error is a low-level database error (e.g. duplicated key), a hardware error, etc. Associated statusText: "Other error" | 
| dk status stamp has changed | 2 | The internal stamp value of the entity does not match the one of the entity stored in the data (optimistic lock). 
 | 
Creating a new entity:
 C_OBJECT($status;$employee)
 $employee:=ds.Employee.new()
 $employee.firstName:="Mary"
 $employee.lastName:="Smith"
 $status:=$employee.save()
 If($status.success)
    ALERT("Employee created")
 End ifUpdating an entity without dk auto merge option:
 C_OBJECT($status;$employees;$employee)
 $employees:=ds.Employee.query("lastName=:1";"Smith")
 $employee:=$employees.first()
 $employee.lastName:="Mac Arthur"
 $status:=$employee.save()
 Case of
    :($status.success)
       ALERT("Employee updated")
    :($status.status=dk status stamp has changed)
       ALERT($status.statusText)
 End caseUpdating an entity with dk auto merge option:
 C_OBJECT($status;$employees;$employee)
 
 $employees:=ds.Employee.query("lastName=:1";"Smith")
 $employee:=$employees.first()
 $employee.lastName:="Mac Arthur"
 $status:=$employee.save(dk auto merge)
 Case of
    :($status.success)
       ALERT("Employee updated")
    :($status.status=dk status automerge failed)
       ALERT($status.statusText)
 End case
	Product:  4D
	Theme:  ORDA - Entity
	
        
        
	
	4D Language Reference ( 4D v18)
	
	
	
 Add a comment
Add a comment