I'm trying to place a copy of a Google Apps Script-file in a shared drive using apps script.
My code looks like this:
function copyFileToSharedDrive(){
var sharedDriveId = "sharedriveidcomeshere";
var sharedDrive = DriveApp.getFolderById(sharedDriveId);
var appsScriptFileId = "appsscriptfileidcomeshere";
DriveApp.getFileById(appsScriptFileId).makeCopy(sharedDrive).setName("This is a copy of the original apps script file");
}
The result, however, is a copy of the apps script file, but it's in my root folder of my Google Drive, instead of in the Shared Drive.
If I do the exact same thing with a Spreadsheet, Google Doc or Slides, the code works like a charm.
I also tried the Advanced Google Services and used the Drive API. No luck there... File is still being created in the root folder of the user executing the code.
Drive.Files.copy(
{title: "This is a copy of the appsscript file", parents: [{id: sharedDriveId}]},
"appsScriptFileId",
{supportsAllDrives: true}
);
Any help?