class LockService method .tryLock()

LockService is the Apps Script service.

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

What it does

Tries to acquire the lock without waiting.

Why it's used

  • Skip a run if someone else is already processing.
  • Show still working instead of piling on conflicts.

Common errors

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

Explore

Related methods

Better Sheets tutorials

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