Ok, this is my function.
.gs
function createIfNotExistSheet( name = 'Controller Settings' ) {
var resp = "";
try {
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var newSheet = activeSpreadsheet.getSheetByName(name);
if (newSheet == null) {
newSheet = activeSpreadsheet.insertSheet();
newSheet.setName(name);
}
resp = "Sheet "+ name +" are ready, at id = "+ newSheet.getSheetId();
}
catch (e) {
resp = e;
}
finally{
Logger.log(resp);
return resp;
}
}
I call it from js with:
js.
settingsFile = google.script.run.createIfNotExistSheet(cC.settingsFile['name']);
Whether I call it with or without the argument the result does not change, settingsFile returns undefined.