Hi everyone,
I’ve been using Google Apps Script for a while, and I recently noticed an unexpected change in how the spreadsheet.copy() method behaves.
The Issue: I have a simple script that copies a template spreadsheet. Until recently, executing this script would automatically create the copied file in the root of “My Drive”.
However, when I ran it today, the file was not created in My Drive. Instead, it seems to be created in an unknown location (I suspect they are being created as orphaned files without a specific parent folder).
Here is the code I am using:
JavaScript
const download_template = SpreadsheetApp.openById('/* spreadsheetID */');
const copyFiles = download_template.copy('Budget_Tool_v1.00');
My Questions:
-
Has there been any recent specification change or undocumented update regarding the default destination folder for the
spreadsheet.copy()method? -
Is this a known bug, or is anyone else experiencing the same issue?
(Note: I am aware that using DriveApp.getFileById(id).makeCopy(name, destinationFolder) is the best practice to explicitly set the destination. However, I have several legacy scripts using SpreadsheetApp.copy() and would like to understand the root cause of this sudden change.)
Thank you in advance for any insights or information!