1
votes

I have a problem similar to one posted on the Google Product Forums.

The answer given there described a way which requires action from the recipients of the link to make a copy of the Google Spreadsheet by themselves.

There is a script, which creates a personal folder for a person who wants to edit the COPY of the Google Spreadsheet. Than the the ORIGINAL Google Spreadsheet copied into a newly created folder:

fileforanswers.makeCopy(fileforanswers.getName(), targetFolder);

The permissions for the COPY set:

fileforanswers.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT)"

The Google Spreadsheet contains 1 sheet. The protection settings for the COPY of the Google Spreadsheet "SHEET" are:

if (protection && protection.canEdit()) { protection.remove(); }

For the "RANGE" are:

if (protection && protection.canEdit()) { protection.remove(); }

The link contains the ID of the COPY of the Google Spreadsheet. When the COPY of the Google Spreadsheet accessed by its own link directly by a person who wants to fill it Google Sheets allows to VIEW it only

The settings described above are set manually for the ORIGINAL Google Spreadsheet. When the ORIGINAL Google Spreadsheet accessed by its own link by the same person the same way described in case of the COPY, Google Sheets allows to EDIT the ORIGINAL.

What else required to allow in the script to enable editing of the COPY of the Google Spreadsheet?

1

1 Answers

0
votes

The .makeCopy method returns the copy file. your second code line appears to explain what you are describing in that you are setting the sharing on thefile you have copied and not the copy.

Try setting the permissions on the returned File object:

var copyOfOriginal = fileforanswers.makeCopy(fileforanswers.getName(), targetFolder);

copyOfOriginal.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT)"