Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phillypb/60cd370a190bd5a62a09ad53fec7a8b3 to your computer and use it in GitHub Desktop.
Save phillypb/60cd370a190bd5a62a09ad53fec7a8b3 to your computer and use it in GitHub Desktop.
/**
* Function to change ownership of a Google Drive item (within your organisation) without sending an email
* notification.
*
*
* DEVELOPED BY THE GIFT OF SCRIPT: https://www.pbainbridge.co.uk/
*/
function changeOwnership() {
// ID of the item to change ownership of
var itemID = "ENTER HERE";
// email address of the new owner
var newOwnerEmail = "ENTER HERE";
// create permission resource for sending to Drive API
var resource = {
// set the role to owner
role: "owner",
// choose from "user" or "group" (if using a Google Group)
type: 'user',
// provide the email address of the new owner
value: newOwnerEmail
};
// create optional arguments
var optionalArgs = {
// make compatible with Google Shared drives
supportsAllDrives: true,
// disable sending of automated notification email to new owner
sendNotificationEmails: false
};
// call Drive API to change ownership
Drive.Permissions.insert(resource, itemID, optionalArgs);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment