I'm trying to create a budgetting file in Google Sheets that my collegues can make a copy of and then use it for their specific project. With this copy I want to keep my original protected sheets with me as an owner and the only one who can change them (if they just copy the file, they become the file-owner and are then able to change my blocked cells).
I found a code that should do this, but it gives me this error: Exception: Unexpected error while getting the method or property getFileById on object DriveApp. Does any know how to fix this?
What I Did: I've added scopes to the manifest file (appscript.json). Which looks like this:
{
"timeZone": "Europe/Brussels",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "Sheets",
"version": "v4",
"serviceId": "sheets"
}
]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive"
]
}
And the first bit of code (with the property getFileById in it) is:
function Main() {
var template = DriveApp.getFileById('1839156158');
var destination = DriveApp.getFolderById('1ajqwefqcjwefjipqjpo11');
var curDate = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyy-MM-dd");
var copyName = '[NAME FESTIVAL]' + template.getName() + curDate;
copyTemplate(template, copyName, destination);
}