Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 30
Registered: ‎02-05-2013
My Device: 9860
My Carrier: Vodafone
Accepted Solution

Regarding findEvents() method in Calendar

Hi,

 

I am trying to use findEvents() method to retrieve the calendar events set to the native calendar application but I am getting an exception saying " 'undefined' is not a function ". This means findEvents() is not a function.

 

blackberry.pim.calendar.findEvents(findOptions,onFindSuccess,onFindError);

 

Please let me know if anything is wrong in the code below:

 

function onFindSuccess(events) {
   alert("Found " + events.length + " events!");
   events.forEach(function (evt) {
      alert("Event summary: " + evt.summary);
      alert("Event location: " + evt.location);
   });
}

function onFindError(error) {
   alert("Error: " + error.code);
}

 

function findEventsByKeyword(startTime,endTime,title,match_id) {
    alert("test3");    
        
    var filter = {'substring': title,
                  'start'     : Date.parse(startTime),
                  'end'      : Date.parse(endTime),
                 };

    alert("test4");    
                
    var findOptions = {
       'filter' : filter,
       //'detail' : blackberry.pim.calendar.CalendarFindOptions.DETAIL_FULL
    };
    
    alert("test5");
    try {
        // Find all events that has the specified keyword in summary,
        // location or attendees' name/email
        blackberry.pim.calendar.findEvents(findOptions,onFindSuccess,onFindError);
    } catch(e) {
        alert(e);
    }
}

 

Awaiting your response.

 

Thanks in advance.

Highlighted
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Regarding findEvents() method in Calendar

That error would point more at the application setup (i.e. config.xml) than your JavaScript implementation.

Have you compared against the sample here?
https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/pimcalendar

Specifically that you've added this feature:
<feature id="blackberry.pim.calendar" />

And this permission:
<rimSmiley Tongueermit>access_pimdomain_calendars</rimSmiley Tongueermit>

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Regarding findEvents() method in Calendar

Just wanted to follow-up to see if the suggestion above resolved the issue or if you are still experiencing problems.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Contributor
Posts: 30
Registered: ‎02-05-2013
My Device: 9860
My Carrier: Vodafone

Re: Regarding findEvents() method in Calendar

Hi,

 

Thanks for your reply. The issue in my code was with the Date.parse usage in the start and end parameters. The following filter definition is working fine.

 

    var filter = {'substring': title,
                  'start'     : startTime,
                  'end'      : endTime
                 };

 

Thanks again.