Sorry I'm not familiar with coding, I have a spreadsheet with multiple worksheets, it's shared with many people, I'm trying to make those sheets hidden by defaults when it's shared with a new person, and define some users as an admin users, and user groups for each location, I could run the code, and it worked when it was shorter, I know there might be easiest ways, however do you beilive there is a speific reason I'm getting nothing running the code, and users still see the hidden sheets unless I delete the IF statements.
Many thanks in advance.
function onOpen() {
var Adminusr= ['amw22test.com','[email protected]','[email protected]'];
var Germanyusr = ['[email protected]', '[email protected]'];
var Austriausr = ['[email protected]', '[email protected]'];
var Greeceusr = ['[email protected]'];
var Polandusr = ['[email protected], [email protected]'];
var Spainusr = ['[email protected], [email protected], [email protected], [email protected]'];
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Germany').hideSheet()
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Austria').hideSheet()
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Greece').hideSheet()
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Poland').hideSheet()
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Spain').hideSheet()
if (Adminusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0 || Germanyusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Germany').showSheet()
}
if (Adminusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0 || Austriausr.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Austria').showSheet()
}
if (Adminusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0 || Greeceusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Greece').showSheet()
}
if (Adminusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0 || Polandusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Poland').showSheet()
}
if (Adminusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0 || Spainusr.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Spain').showSheet()
}
}