Created
July 12, 2024 10:47
-
-
Save phillypb/60cd370a190bd5a62a09ad53fec7a8b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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