GAS – Restore Data Validation

A downside with GAS spreadsheets is the inability to share them and properly protect them at the same time, whilst remaining usable by an end user. So if I want an “unknown” and “untrusted” user to access the sheet and select from dropdowns etc., i must give them editing rights.

This example shows how to check and restore a cell validation each time the sheet is opened.

here is the code:

Here is the link to the spreadsheet:

Protection Test

You can test it out by changing the colour of the drop down cell or by editing, removing the validation. Then refresh the spreadsheet.

This type of “restoration” work can be applied to all manner of content and formatting, if necessary using the onChange event to test and fix things on the fly (although might get a bit cumbersome for the end user. The only problem being that the end user can still go into the script editor and delete all the code, if signed in! (Please don’t!)

Leave a Reply

Your email address will not be published. Required fields are marked *