My code processes and merges user submitted Google Form data into a Google Doc, shares the file with users determined through Google Sheet Functions, and emails a notification of the new submission to those same users.
The group of users starts as a single value (list in the cell -- user1@email.com, user2@email.com, etc.
) and is then split(", ")
into an array for use in addEditors()
.
I need to set editing permissions for those users without sending the email notification associated with that action while using the DriveApp File.addEditors()
method. As I understand it, this requires the Advanced Drive Service, which I have already enabled for the script.
What is the syntax and exact code for adding these permissions without notification?
Sample of my code below --
function mergeApplication() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Merge Data");
var range = sheet.getActiveRange();
var formSheet = ss.getSheetByName("Form Responses");
var lastRow = formSheet.getLastRow();
var lastColumn = sheet.getMaxColumns();
function checkAndComplete() {
var urlColumn = lastColumn;
var checkColumn = (urlColumn - 1);
var checkRange = sheet.getRange(2, checkColumn, (lastRow - 1), 1);
var check = checkRange.getBackgrounds();
var red = "#ff0404";
var yellow = "#ffec0a";
var green = "#3bec3b";
for (var i = 0; i < check.length; i++) {
if (check[i] == green) {
continue;
} else {
var statusCell = sheet.getRange((i+2), checkColumn, 1, 1);
var urlCell = sheet.getRange((i+2), urlColumn, 1, 1);
var dataRow = sheet.getRange((i+2), 1, 1, (lastColumn - 2));
var emailTag = sheet.getRange((i+2), (checkColumn - 2)).getValue();
var emailEditors = emailTag.split(", ");
...skipping down through merge code to where it will be used...
var docCopy = docToUse.makeCopy(docName, folderDestination);
var docId = docCopy.getId();
var docToSend = DriveApp.getFileById(docId);
docToSend.addEditors(emailEditors);
Here's a utility function to silently give a user write permissions on a Google Drive file.
Now, instead of:
Use: