I currently have a Google Spreadsheet with two columns - the file ID of a set of files, the file name. I want to write a Google Apps Script where when I change the file name within the spreadsheet, it renames the file associated with it (fileID) to the new name and vice versa.
With changing it on the spreadsheet, should I use simple/installable onEdit or onChange, and how might I implement this in code. I don't know how to do this vice versa as well.
Here's what I have so far, but the trigger has failed quite a few times. It's throwing the exception:
Exception: The parameters () don't match the method signature for SpreadsheetApp.Spreadsheet.getRange.at onEdit(edit:3:24)and
Exception: You do not have permission to call SpreadsheetApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets var sheet = SpreadsheetApp.openById("xxx").getSheetByName("New"); var range = e.source.getRange(); range.setComment("Last modified: " + (new Date())+' by '+Session.getActiveUser()); Logger.log(range.getRow() +" " + range.getColumn()); var newName = range.getValue(); var fileID = sheet.getRange(range.getRow(), 1).getValue(); if (range.getColumn == 3) { // just some data validation to make sure the edited cell is in column 3 Logger.log(range.getValue()); var file = DriveApp.getFileById(fileID); file.setName(newName); }