Update a calendar entry with no notification

You can update a calendar entry on a BlackBerry® device without sending notifications to the entry's participants.

  1. Import the required classes and interfaces.
    import java.util.*;
    import javax.microedition.pim.*;
    import net.rim.blackberry.api.pdap.BlackBerryEvent;
    import net.rim.blackberry.api.pdap.BlackBerryEventList;
    import net.rim.blackberry.api.pdap.BlackBerryPIMItem;
  2. Invoke PIM.openPIMList() to open a list of calendar entries as a BlackBerryEventList object.
    BlackBerryEventList eventList = null;
    try 
    { 
       eventList = (BlackBerryEventList) 
          PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE); 
    }
    catch (PIMException e) 
    {
       // Handle exception
    }
  3. Retrieve a BlackBerryEvent object from the list of entries.
    Enumeration events = eventList.items();
    BlackBerryEvent event = (BlackBerryEvent) events.nextElement();
  4. Modify the entry.
    if (eventList.isSupportedField(Event.SUMMARY)) 
    {
       event.addString(Event.NOTE, Event.ATTR_NONE, "Remember to bring food");
    }
  5. Invoke BlackBerryPIMItem.commit() and specify the flag BlackBerryEvent.DO_NOT_NOTIFY_ATTENDEES to save your changes.
    if(event.isModified()) 
    {
       try
       {
          int result;
          result = 
           ((BlackBerryPIMItem) event).commit(BlackBerryEvent.DO_NOT_NOTIFY_ATTENDEES);
       }
       catch (PIMException e) 
       {
          // Handle exception
       }
    }

    If you specify BlackBerryEvent.DO_NOT_NOTIFY_ATTENDEES when committing changes to a calendar entry, notification is not sent unless the calendar entry is a new meeting or meeting participants have been added since the last update (meeting participants must be notified about the meeting in order to accept the meeting invitation). If notification was sent, BlackBerryPIMItem.commit() returns BlackBerryEvent.MEETING_RECORD_NOT_FOUND or BlackBerryEvent.INVITEE_LIST_CHANGED.

Code sample

BlackBerryEventList eventList = null;
try 
{ 
   eventList = (BlackBerryEventList) 
      PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE); 

   Enumeration events = eventList.items();
   BlackBerryEvent event = (BlackBerryEvent) events.nextElement();
               
   if (eventList.isSupportedField(Event.SUMMARY)) 
   {
      event.addString(Event.NOTE, Event.ATTR_NONE, "Remember to bring food");
   }
               
   if(event.isModified()) 
   {
      int result;
      result = 
         ((BlackBerryPIMItem) event).commit(BlackBerryEvent.DO_NOT_NOTIFY_ATTENDEES);
   }
}
catch (PIMException e) 
{
   // Handle exception
}

Was this information helpful? Send us your comments.