David Stockdale's Scrapcode

Lock Google Docs On Shared Drives

When working in collaborative environments, especially with sensitive documents stored in shared drives, you may need to enforce stricter permissions to prevent unwanted edits.

Here’s a simple bit of Google Apps Script for locking a document (effectively making the document read-only).

const document = DocumentApp.openById(<YOUR DOC ID HERE>);

Logger.log("Document ID: " + document); //Just here for testing.

Drive.Files.patch({contentRestrictions: [{readOnly: true}]}, document, {supportsAllDrives: true});

Hopefully this will make someone’s google search a bit quicker.

Leave a like or a comment if it helped!

Leave a Reply