TomClarke
TomClarke

Reputation: 13

Change Google Sheet sharing settings using Google App Script

I have a script that creates a number of Google sheets (by duplicating a master and then adding specific data to each sheet) when it runs and puts each sheet into a different folder. Each folder is shared with different people (editors) so different people can see each sheet.

For each sheet that is created I want to stop each editor being able to share the file with others.

I have found how to check this permission using file.isShareableByEditors() but I cannot see how to change it.

The master file that I am duplicating does have this setting enabled however when duplicating the permission is not carried over.

Upvotes: 1

Views: 1456

Answers (1)

TheMaster
TheMaster

Reputation: 50452

The method setShareableByEditors prevents file sharing by editors:

const stopEditorsFromSharingFile_ = file => file.setShareableByEditors(false)

Upvotes: 1

Related Questions