I'm very new to scripting, and I'm having an issue with the copy function, as well as finding newer relevant information.
My end goal is to copy a google workbook in a shared folder to another shared folder with a new name.
Currently I am simply trying to copy the workbook to a new name in the same folder, but the script puts it in my folder and not the shared.
Below is the very simple script I had written. If I do the copy manually through the google sheet copy function, I can put the newly named sheet anywhere. I tried to record these steps as a macro, but that did nothing. As an FYI the Dfolder and Cfolder variables are the names of shared folders. The function is to place the copied workbook in one of these 2 folders depending upon a cell value.
function MakeCopy() {
let Dfolder = "Defect PreTrips"
let Cfolder = "Clean PreTrips"
let SheetName = SpreadsheetApp.getActive();
let Truck = SheetName.getRange("E3").getValue();
SheetName.getRange("C3").setValue(new Date());
Tday = SheetName.getRange("C3").getDisplayValue();
if (Truck != "")
{
SheetName.copy("Pretrip " + Truck + " " + Tday);
ClearSheet();
}
else
{
Browser.msgBox("Truck required");
}
};