Sheet: list of user's names row[0] list of user emails row[5]
run the script it works fine apart from this line
DriveApp.getFileById('1phsJs4ik2a654645645GOJs4gBVVKd2OmlHtlPk').makeCopy(sheetName,dest).addEditor(owner);
ERROR: Invalid argument: permission.value (line 21, file "Code")
Works fine when i replace the 'owner' with '"email@google.com"' but i need it to iterate through a list
Full code:
// Showing it has been sent.
var Confirmed = "Confirmed";
function DistributeTemplate() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var specify = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var counter = specify.getRange("A1").getValue(); //HOW MANY TO DO
var numRows = counter; // Number of rows to process
var dataRange=sheet.getRange(startRow, 1, numRows, 5)
var data = dataRange.getValues();
var dest = DriveApp.getFolderById('INSERTFOLDERID');
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var sheetName = row[0]
var FlexisheetSent = row[2];
var owner = row[5];
Logger.log(owner);
if (FlexisheetSent != Confirmed) { //Only send once
//DriveApp.getFolderById(dest).addEditor(owner);
DriveApp.getFileById('INSERTTEMPLATEIDGOOGLESHEET').makeCopy(sh eetName,dest).addEditor(owner);
sheet.getRange(startRow + i, 3).setValue(Confirmed);
// The cell is updated instantly to avoid any issues.
SpreadsheetApp.flush();
}
}
}