Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 06:49, 5 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Adding and deleting calendar events in Symbian Web Runtime

From Wiki
Jump to: navigation, search

This code example shows how to add and delete calendar entries on Symbian Web Runtime.

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Platform(s): S60 5th Edition
S60 5th Edition
Keywords: device.getServiceObject(), Service.Calendar.Add(), Service.Calendar.Delete()
Created: ivruban (10 Dec 2008)
Last edited: hamishwillee (05 Oct 2012)



The example uses the Calendar Platform Service, introduced in S60 5th Edition.

To obtain access to the service object for the Calendar Service API, the device.getServiceObject("Service.Calendar", "IDataSource") method is used.

Source: Relevant HTML components

<input type="radio" name="eventType" id="meeting" checked
<label for="meeting">Meetings</label><br />
<input type="radio" name="eventType" id="anniversary"
<label for="anniversary">Anniversaries</label><br />
<input type="radio" name="eventType" id="dayEvent"
<label for="dayEvent">Day Events</label><br />
<input type="radio" name="eventType" id="reminder"
<label for="reminder">Reminders</label><br />
<input type="radio" name="eventType" id="toDo"
<label for="toDo">ToDos</label><br />
<label for="entriesList">Entries:</label><br />
<select size="2" id="entriesList"></select><br />
<input type="button" value="Add" id="add" onclick="addEntry();">
<input type="button" value="Delete" id="delete" onclick="deleteEntry();">

Source: JavaScript file

var serviceObj = null;
window.onload = init;
// Initializes the widget
function init() {
// Obtain the service object
try {
serviceObj = device.getServiceObject("Service.Calendar",
} catch (ex) {
alert("Service object cannot be found.");
function showEntries() {
// Showing calendar entries is omitted here for brevity. Refer to the See
// also section of the snippet for more information.
// ...
function addEntry() {
var item = new Object();
item.Type = "Meeting";
var startDate = new Date("January 6, 2009 19:05:00");
var endDate = new Date("January 7, 2009 20:05:00");
item.StartTime = startDate;
item.EndTime = endDate;
var criteria = new Object();
criteria.Type = "CalendarEntry";
criteria.Item = item;
try {
var result = serviceObj.IDataSource.Add(criteria);
if (result.ErrorCode == 0) {
} else {
alert("Error in adding calendar entry");
} catch (ex) {
alert("Error in adding calendar entry: " + ex);
function deleteEntry() {
// Get the selected calendar entry
var entriesList = document.getElementById("entriesList");
var entryId = "";
for (var i = 0; i < entriesList.options.length; i++) {
if (entriesList.options[i].selected) {
entryId = entriesList.options[i].value;
var criteria = new Object();
criteria.Type = "CalendarEntry";
criteria.Data = new Object();
criteria.Data.LocalIdList = new Array();
criteria.Data.LocalIdList[0] = entryId;
try {
var result = serviceObj.IDataSource.Delete(criteria);
if(result.ErrorCode == 0) {
} else {
alert("Error in deleting calendar entry");
} catch (ex) {
alert("Error in deleting calendar entry: " + ex);


The user can add and delete calendar entries by pressing the Add and Delete buttons.

Supplementary material

You can view the source file and executable application in the attached ZIP archive. The archive is available for download at Media:Adding and deleting calendars events in

See also

Listing calendar entries in Symbian Web Runtime

This page was last modified on 5 October 2012, at 06:49.
86 page views in the last 30 days.