I created a form that logs entries into a Google Sheet. Once a day, I want the spreadsheet to be emailed, as an attachment, to our technician. At the same time I want to make a copy of the spreadsheet, as a "record", in a specific folder. I use the following code
function sendEmail() {
var oauthConfig = UrlFetchApp.addOAuthService("google");
oauthConfig.setAccessTokenUrl("url");
oauthConfig.setRequestTokenUrl("url");
oauthConfig.setAuthorizationUrl("url");
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
var requestData = {"method": "GET", "oAuthServiceName": "google", "oAuthUseToken": "always"};
var url = "url";
var result = UrlFetchApp.fetch(url , requestData);
var contents = result.getContent();
var cur_date = Utilities.formatDate(new Date(), "GMT+1", "yyyy/MM/dd")
MailApp.sendEmail("[email protected]","test" ,"test", {attachments:[{fileName:cur_date + "_Orders.html", content:contents, mimeType:"application/html"}]});
var spreadsheet = DriveApp.getFileById("ID")
spreadsheet.makeCopy(cur_date + "_Orders", DriveApp.getFoldersByName("Orders").next());
}
The problem I have is that when the "old" spreadsheet is copied, into the new folder, obviously the associated script is also copied alongside and a copy of the form linked to the spreadsheet. Is there a way to copy the spreadsheet only (that is, the data in the cells), without all the attached "frills".
Cheers, Nicola