Lock + Unlock cells in sheets - Testing help needed

107 views
Skip to first unread message

Ed Robinson

unread,
May 5, 2024, 11:13:20 AM5/5/24
to Google Apps Script Community
I've developed a solution to the problem "how to lock Google Sheets cells after people edit them"

The technique works like this:
1. The sheet's permissions are "Anyone can edit", but the sheet itself is locked
2. A user clicks an "Edit button" to begin editing
3. Edit button calls a method in a separate web app (executing as the sheet owner)
4. Web app - executing as the sheet owner - has the privileges to unlock/lock the cell

With this technique, you can:
- Create locked forms in Google Sheets with editable fields
- Capture audit history
- Lock cells after someone has finished editing

This permissions stuff is challenging to debug!

Before I publish the sample code, I need help testing it works. 
If you'd like to help (use the sample, and let me know if it works), please email me: ed [at] parclay [dot] com.

Ed

Ed Robinson

unread,
May 26, 2024, 6:24:47 PM5/26/24
to Google Apps Script Community

The sample demonstrates how to:
  • Create locked forms in Google Sheets with editable form fields
  • Capture audit history when people edit the form fields
  • Unlock a single cell for editing, then lock the cell after they have finished
  • Programmatically lock/unlock a cell based on business rules, such as "a user can only edit empty cells" or "person x can override text in any cell"

I've also packaged into a Spreadsheet that auto-copies itself into your Google My Drive. Hope this is useful for answering the common "how do I lock cells?" question
Reply all
Reply to author
Forward
0 new messages