{"title":"Record.LockTable([Boolean] [, Boolean]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/record/record-locktable-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-locktable-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-locktable-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Starts locking on a table to protect it from write transactions that conflict with each other.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Record.LockTable([Boolean] [, Boolean]) Method","slug":"recordlocktableboolean-boolean-method","at":0,"chars":2543},{"level":2,"title":"Syntax","slug":"syntax","at":204,"chars":81},{"level":2,"title":"Parameters","slug":"parameters","at":285,"chars":651},{"level":2,"title":"Remarks","slug":"remarks","at":936,"chars":1390},{"level":2,"title":"Related information","slug":"related-information","at":2326,"chars":217}],"text":"# Record.LockTable([Boolean] [, Boolean]) Method\n> Version: _Available or changed with runtime version 1.0._\nStarts locking on a table to protect it from write transactions that conflict with each other.\n## Syntax\n```al\n Record.LockTable([Wait: Boolean] [, VersionCheck: Boolean])\n```\n## Parameters\nRecord\nType: record-data-type\nAn instance of the record-data-type data type.\n*[Optional] Wait*\nType: ../boolean/boolean-data-type\nSpecifies what to do if the table is already locked. If this parameter is true and if another application has already locked the table, the system will wait until the table is unlocked. If this parameter is false and if another application has already locked the table, a run-time error occurs.\n*[Optional] VersionCheck*\nType: ../boolean/boolean-data-type\nIf this parameter is true, the version of the Record will be checked. If this parameter is false, blank, or not used, the version will not be checked.\n## Remarks\nRead scale-out lets databases offload read-only workloads to read-only replicas, isolating them from the main read-write workload to improve performance. See Using read scale-out for better performance<../../../administration/database-read-scale-out-overview>.\nLockTable behaves differently depending on whether read scale-out is used. If the session doesn't use read scale-out, LockTable does these actions:\n1. Starts a transaction.\n1. Makes sure that all subsequent statements that read data apply an UPDLOCK on the database.\nIf the session uses Read Scale-Out, LockTable does the following:\n1. Makes sure that all subsequent statements that read data use REPEATABLEREAD on the database.\nBecause all write operations automatically lock the table that is being used, LockTable would appear unnecessary. However, you could have a transaction in which an application wants to inspect data before possibly changing it, with a guarantee that the data being changed has not been modified by other applications since the read operation. The solution is to explicitly lock the table before the read operation. This makes sure that no other application makes changes between the read operation and the possible write operation.\nThe table lock is released (unlocked) when the transaction is committed.\nThis method works the same as the RecordRef ../recordref/recordref-locktable-method.\n## Related information\nrecord-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\n../../../administration/optimize-sql-al-database-methods-and-performance-on-server"}