class LockService method .getDocumentLock()

LockService is the Apps Script service.

.getDocumentLock() is the method name you will see after a dot in your code.

What it does

Returns a lock tied to the current spreadsheet or doc.

Why it's used

  • Guard this spreadsheet when several editors trigger automation.
  • Avoid corrupted data when form submits overlap.

Common errors

  • Forgetting parentheses on getDocumentLock. Write LockService.getDocumentLock(), not LockService.getDocumentLock or getDocumentLock by itself.
  • Skipping dots between chained calls. Each step needs a dot, like LockService.getDocumentLock().
  • Adding spaces where they do not belong. Write LockService.getDocumentLock(), not LockService .getDocumentLock(), LockService.getDocumentLock (), or LockService . getDocumentLock().
  • Wrong capitalization. Use LockService and getDocumentLock, not lockservice or getdocumentlock.

Explore

Related methods

Better Sheets tutorials

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.