class LockService method .waitLock()

LockService is the Apps Script service.

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

What it does

Waits until the lock is available, then acquires it.

Why it's used

  • Queue up work until the previous run finishes.
  • Safer than crashing when two executions collide.

Common errors

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

Explore

Related methods

Better Sheets tutorials

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