I'm not familiar with Google Apps Script and I'm having trouble figuring out how to call a function.
The below function is intended to move a file from the Google Shared Drive folder its current in to a new folder with the Google Shared Drive.
function moveFilesBetweenSharedDrives({parentFolderId, destinationFolderId, fileId }) {
const data = Drive.Files.update({}, fileId, null, {
addParents: destinationFolderId,
removeParents: parentFolderId,
supportsAllDrives: true,
fields: 'title, embedLink',
});
console.log('File Moved', data.title, data.embedLink);
}
I tried to call this function in a macro style with the below code but that didn't work. In the google apps script page, a syntax error would show up saying: "Syntax error: SyntaxError: Invalid or unexpected token line: 11 file: Code.gs":
moveFilesBetweenSharedDrives(1FaTWCQc-asflsdfsfAngr, 1setTISPSknysd-sl3UepcFnptDCA, 1R9gLCWpsfasafsdf-9QZwef44HKLCI)
What am I doing wrong? I had selected the function and inputted the Shared Drive Folder Ids for the original folder, destination folder, and the file ID. I've also enabled the Drive API, so I'm unsure how to properly call the function.
//I've removed the curly brackets from this function signature.
function moveFilesBetweenSharedDrives(parentFolderId, destinationFolderId, fileId) {
...
//To call the function, the parameters must be in String format (within quotes).
moveFilesBetweenSharedDrives("<PARENT_FOLDER_ID>", "<DESTINATION_FOLDER_ID>", "<FILE_ID>")
Additionally, make sure the caller/actor of the function have Contributor
, Content manager
, or Manager
roles over both parent Shared Drive and Destination.
If fileId
is a folder, make sure the caller is a Workspace Drive Administrator.
For more inforamtion regarding requisites to moving files to Shared Drives, please refer to this Help Center article