I'm trying to copy a template spreadsheet to a new spreadsheet. It does manage to create the tabs from the template, but all the tabs are blank/unaffected.
I got access and edit permission to both the template/source and the destination sheet.
When I run the debug in the Google Script Editor I get "sourceSheet" as an object and when I check it with getName() it shows the name of the template and "source" shows the name of the tab from the template.
function onOpen(e){
var installedStatus = PropertiesService.getScriptProperties().getProperty("installed");
if(installedStatus != "true"){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var documentName=ss.getName();
if(ss.getName() == "Namnlöst kalkylark"){
ss.rename("Dashboard 2.0 - (Kundens namn)");
}
var omKund = ss.getSheetByName("Om kund");
if(omKund == null ){
copySheets("Om kund");
}
PropertiesService.getScriptProperties().setProperty("installed", "true");
}
}
function copySheets(tabname){
var sourceSheet = SpreadsheetApp.openById("ID to template spreadsheet here");
var source = sourceSheet.getSheetByName(tabname);
var sValues = source.getDataRange().getValues();
var destination = SpreadsheetApp.openById(SpreadsheetApp.getActive().getId());
source.copyTo(destination);
var destinationSheet = destination.getSheetByName("Copy of "+sourceName);
destinationSheet.getRange(1,1,sValues.length,sValues[0].length).setValues(sValues);
destinationSheet.setName(sourceName);
}'