0

I have one backend function to append new rows to a Google Sheet and a lock service is used to prevent the conflicts of multiple users.

sh.appendRow(record);

Another backend function is to delete rows from the same sheet and a lock service is used as well.

sh.deleteRow(posIndex+2)

While I have concern that one user is appending a row at the same time as another user is deleting a row, will it cause any trouble? Since the lock service is used independently in these two functions, they will not lock each other.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Guisheng
  • 13
  • 2

1 Answers1

1

The Lock Service has three scopes,

  • User
  • Document
  • Script

Using the the document scope is very likely to be the best option. For this use getDocumentLock().

Related

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • This is a standalone script and my understanding is the document lock is for the script in the google sheet. Is that correct? Thank you. – Guisheng Jul 12 '21 at 19:16