class DriveApp method .setSharing()

DriveApp is the Apps Script service.

.setSharing() is the method name you will see after a dot in your code.

What it does

Changes who can view or edit a file or folder.

Why it's used

  • Share a new report with the client as soon as it is generated.
  • Lock down or open up files based on a status column.

Common errors

  • Forgetting parentheses on setSharing. Write DriveApp.setSharing(), not DriveApp.setSharing or setSharing by itself.
  • Skipping dots between chained calls. Each step needs a dot, like DriveApp.getFileById(id).setSharing().
  • Adding spaces where they do not belong. Write DriveApp.setSharing(), not DriveApp .setSharing(), DriveApp.setSharing (), or DriveApp . setSharing().
  • Wrong capitalization. Use DriveApp and setSharing, not driveapp or setsharing.

Explore

Related methods

Better Sheets tutorials

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.

Related blog posts

Written guides about DriveApp.setSharing().

Browse the blog