Protecting your data

While we are taking care of data privacy, let's have a quick peek at data protection using Google Apps Script.

Google has introduced this ability quite recently and it opens a few interesting perspectives.

The following is an example of a script that protects a sheet after a user has added a value in a particular cell:

function myFunction(e) { var sheetIndex = e.source.getSheets().length;// to know how many sheets we already have var sourceValues = e.source.getActiveSheet().getDataRange().getValues();//get all the data from this sheet var cell = e.source.getActiveRange().getA1Notation();//get A1 notation for comfort of use Logger.log('SheetName:'+e.source.getActiveSheet().getSheetName()+' user:'+Session.getActiveUser()); if(cell=='A1' ...

Get Google Apps Script for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.