Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Prevent Google spreadsheet editor from accessing GAS by using detached GAS

$
0
0

The solution is sketched in this post, but it seems key steps are not identified.This code works fine if in GAS bound to the spreadsheet:

function onEdit(e) {   var sheet      = e.source.getActiveSheet();   var activeCell = sheet.getActiveCell();   var row        = activeCell.getRow();   if(row != 1) {     sheet.getRange(row, 4).setValue(new Date().toISOString())    }}

In the owner account's G-drive, I created a script as follows:

function onEdit(e) {   var ss         = SpreadsheetApp.OpenFileById("[spreadsheet ID]");   var sheet      = ss.getActiveSheet();   var activeCell = sheet.getActiveCell();   var row        = activeCell.getRow();   if(row != 1) {     sheet.getRange(row, 4).setValue(new Date().toISOString())    }}

But this script does not set the date value in the active sheet when an edit is made. I deployed this detached script (as webapp) and gave it permission to access the spreadsheet. But I suspect there are other steps or I have not properly deployed the script so that it can respond to edits in the active sheet of the spreadsheet.


Viewing all articles
Browse latest Browse all 9782

Trending Articles