Advanced Google Sites Tip — Create Announcements from Calendar Events

Google Sites has the ability to insert Google Apps related gadgets like Calendars. This can be done by editing a web page, clicking “Insert” from the edit navigation and selecting the “Calendar gadget”.

For those important events, many will emphasize it with a post on an Announcement web page.

Did you know it’s possible to automate this process? It’s true! Add a calendar event, wave your magic wand, and it magically appears on your site’s web page as a posted announcement.
Usually magicians don’t reveal their secrets, but for a limited time you can get it for only $9.99 (not available in stores). Order now and we will include the secret of Making your money disappear — just pay separate processing and handling.
Just kidding.
To perform this trick you need a Google Calendar, an existing Google Sites Announcement web page, and a Google Apps Script.
Prepare the Magic
1. Get the name of the Google Calendar that you want to post on a web page.
2. Copy the URL of the Google site announcement web page that was created with the Announcement web page template.
3. Copy the below Google Apps Script into a Google site or spreadsheet script editor.
function updateAnnouncementPage() {
var annPage = SitesApp.getPageByUrl(“PASTE_ANNOUNCEMENT_PAGE_URL_HERE”);
// Enter date range ..
With more coding you can get today’s and tomorrow’s date
// for the range and run the script once a day.
var startDate = new Date(“04/01/2012”);
var endDate = new Date(“04/07/2012”);
var events = CalendarApp.openByName(“ENTER-CALENDAR-NAME-HERE”)
.getEvents(startDate, endDate);
for (var i = 0; i < events.length; i++) {
var message = events
[i].getDescription() + ” (Event is from ” +
events[i].getStartTime() +
” until ” + events[i].getEndTime() + “)”;
annPage.createAnnouncement(events[i].getTitle() + (i + 1), message);
}
}
4. Insert the calendar name from step #1 in the script code.
5. Insert the announcement web page URL from step #2 in the script code.
6. Update the calendar start and end dates that you want to post.
7. Save the script.
8. Instead of running the script manually, schedule it to run once a day by using a trigger.
Perform the Magic
As you enter events in your calendar, once a day the events are posted in your site’s announcement page!
For Google Apps Script assistance, you can visit the forum.
Give the magic trick a try in your Google Sites and let us know how much you like them in the comments section below! Also if you found this blog post informative, give it a +1 so others can receive the same benefits.

Recent Posts

Go to Top