Samsung Electronics logo

Updating Recurring Calendar Events

To create engaging applications with various calendar features, you must learn to update recurring calendar events:

  1. Retrieve the default system calendar using the getDefaultCalendar() method of the CalendarManager interface.

    Retrieve the calendar event using the get() method by specifying the event ID.

    var calendar = webapis.calendar.getDefaultCalendar();
    var event = calendar.get(evId); 
  2. Expand the recurring event to get its instances by using the expandRecurrence() method of the CalendarEvent:CalendarItem object:
    event.expandRecurrence(new webapis.TZDate(2012, 2, 1), new webapis.TZDate(2012, 2, 15),
                           eventExpandSuccessCB, errorCallback);

    The expanded event instances have their own id.uid and id.rid attributes, where the id.uid attribute is the same for all instances.

  3. Update a single instance of the expanded recurring event.

    In case of recurring events, you can use the second parameter of the update() method to determine whether a single instance or all occurrences of the event are updated. If the parameter is set to true, all instances are updated, while if it is set to false, only the indicated instance of the recurring event is updated (based on the id.rid attribute).

    In this example, the second instance of the event is updated.

    /* Success event handler */
    function eventExpandSuccessCB(events) 
       events[1].summary = 'updated summary';
       calendar.update(events[1], false);