Tech Tip: Entity .lock() and .unlock() should be used on the exact same entity reference
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: December 13, 2021
When calling .lock() on an entity, be sure to use the exact same variable assigned to that entity when calling .unlock(). Otherwise, the .unlock() status will be False. Take the example below:
C_OBJECT($status1; $status2) C_OBJECT($e1; $e2) $e1:=ds.Table_1.get(1) $e2:=ds.Table_1.query("ID = 1").first() $status1:=$e1.lock() // Returns True $status2:=$e2.unlock() // Returns False, entity stays locked |
While both $e1 and $e2 are different variables referencing the same entity, the unlock() will actually not be successful and must be unlocked using $e1. Be mindful of this behavior when trying to manually lock and unlock entities.