4D v18entity.lock( ) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v18
entity.lock( )
|
Property | Type | Description | |
success | boolean | true if the lock action is successful (or if the entity is already locked in the current process), false otherwise. | |
Available only if dk reload if stamp changed option is used: | |||
wasReloaded | boolean | true if the entity was reloaded with sucess, 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_alias | text | Name or alias of the 4D user | |
user4d_id | number | User id 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 (primary key already exists, disk full...): | |||
errors | collection of objects | ||
message | text | Error message | |
component signature | 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 the Result object in case of error:
Constant | Value | Comment |
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).
|
Example with error:
C_OBJECT($employee;$status)
$employee:=ds.Employee.get(716)
$status:=$employee.lock()
Case of
:($status.success)
ALERT("You have locked "+$employee.firstName+" "+$employee.lastName)
:($status.status=dk status stamp has changed)
ALERT($status.statusText)
End case
Example with dk reload if stamp changed option:
C_OBJECT($employee;$status)
$employee:=ds.Employee.get(717)
$status:=$employee.lock(dk reload if stamp changed)
Case of
:($status.success)
ALERT("You have locked "+$employee.firstName+" "+$employee.lastName)
:($status.status=dk status entity does not exist anymore)
ALERT($status.statusText)
End case
Product: 4D
Theme: ORDA - Entity
4D Language Reference ( 4D v18)