Row locking

A row must be locked to delete it or save any changes made to it. A lock is applied when a row is read from a table. Two types of locked can be used: passive and active.

Passive locking

A passive lock allows other users to access the row. They can delete the row or make changes to it. Passive locking ensures that other users accessing the row can be made aware that the row has been deleted or that the contents of the row have changed. A pasive lock is applied every time a row is read using the Change() method.

Hint: The Get() method is used only to read a row. It never locks the row.

Active locking

An active lock allows other users to read the row, but not make any changes or delete the row. Active locking ensures that the user who has the active lock is the only user who can make changes or delete the row. If other users try to delete or change the row, they will receive a sharing error. An ative lock is applied each time a row is read using the Change() method and the activeLock parameter for the method is set to true.

Hint: Not all tables in Microsoft Dynamics GP allow active locking. If you try to actively lock a row on a table that doesn't support it, a NotSupported error will be returned.

Releasing locks

Any of the following actions release a row lock:

  • Using the Release() method.
  • Using the Save() method or the Remove() method, regardless of whether the method was successful.

If a row is currently locked in a table buffer, and you attempt to lock another row, you will receive an DoubleLock error that indicates a row was already locked.