Reputation:
I have code that need to alert today's timetable code is:
function daily() {
var d = new Date();
var number = d.getDay()
var number1 = number + 1
var day1 = ["חשבון והנדסה - דנה","תרבות ישראל - בתיה","אנגלית - בברלי","מדעים (מעבדה) - אורנה","מדעים (מעבדה) - אורנה","מוזיקה - אביטל","אומנות - רננה","ערבית - ז'קלין"];
var day2 = ["מדעים - אורנה","כישורי שפה - לאה","אנגלית - בברלי","אנגלית - בברלי","גיאוגרפיה - ליאת","תרבות ישראל - בתיה","חינוך גופני - אופירה"];
var day3 = ["תנך לאה","גיאוגרפיה ליאת","כישורי חיים - לאה","כישורי שפה - לאה","ערבית - ז'קלין","כישורי שפה - לאה","היסטוריה - ליאת","ערבית - ז'קלין"];
var day4 = ["כישורי שפה - לאה","מדעים - אורנה","סינית/צרפתית","סינית/צרפתית","אומנות - רננה","חשבון והנדסה - דנה","חשבון והנדסה - דנה"];
var day5 = ["מדעים - אורנה","חשבון והנדסה - דנה","מדעים - אורנה","דרמה - חגית","תנך לאה","חינוך גופני - אופירה","היסטוריה - ליאת"];
var day6 = ["אנגלית - בברלי","אנגלית - בברלי","חשבון והנדסה - דנה","חשבון והנדסה - דנה"];
var text = eval("day" + number1) ;
var i = 1;
var tosend = text[0];
while (text[i])
{
tosend = tosend + "\n" + text[i];
i++
}
Browser.msgBox(tosend);
}
The problem is that I got the error:
You do not have permission to call msgbox for this line - You do not have permission to call msgbox
Can you explain me in poor English why I got this error and how to solve it?
I tried to do this and it too didn't work.
alertit(tosend)
}
function alertit(alertthis) {
Browser.msgBox(alertthis)
}
Upvotes: 1
Views: 1457
Reputation: 45740
Browser.msgBox()
may only be used in scripts that are container-bound to a spreadsheet, AND then only when the spreadsheet UI is available.
If you're running this from a time-based trigger, for example, it will fail with that error message because no UI is associated with the trigger's version of the spreadsheet.
You should consider other ways to generate an alert with your timetable, perhaps as sending an email.
Upvotes: 1