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

Native Development

Reply
BlackBerry Development Advisor
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

HOW TO - Edit existing calendar event via invocation

Here is a dirty version of code that does it. Once you have the CalendarEvent object (You can do that with CalendarService APIs), execute the following code:

 

void ApplicationUI::invoke() {
	CalendarService service;
	EventSearchParameters criteria;

	criteria.setStart(QDateTime::currentDateTime());
	criteria.setEnd(QDateTime::currentDateTime().addMonths(1));

	CalendarEvent event = service.events(criteria).at(0); // Get the event we want to edit.

	InvokeManager manager;
	bb::system::InvokeRequest req;
	req.setMimeType("text/calendar");
	req.setTarget("sys.pim.calendar.viewer.eventcreate");
	req.setAction("bb.calendar.EDIT");
	QVariantMap data = QVariantMap();
	data["accountId"] = event.accountId();
	data["eventId"] = event.id();
	data["folder"] = event.folderId();
	data["startTime"] = event.startTime().toString();
	req.setData(PpsObject::encode(data));
	manager.invoke(req);
}

 

Developer
Posts: 1,650
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: HOW TO - Edit existing calendar event via invocation

Shadid,

thanks helping on this

 

integrating Calendar is important and now makes it easy to do all from inside the cascades app

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 1,650
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: HOW TO - Edit existing calendar event via invocation

Hi Shadid,

 

just verified from my Conference Apps: it works :smileyhappy:

 

so this is my pattern:

 

1. Session scheduled ?

    create Calendar Event silently in the background by C++,

    store accountId, entryID, folderId in app (in my case as JSON)

2. User wants to verify or edit the Calendar Entry ?

    read Calendar Entry from C++ (maybe user has deleted entry directly from Calendar App)

    if entry exists, get start time from entry

    Open CalendarEntry Card to EDIT using AccountId, EntryId, FolderId, StartTime

 

works great

 

thanks figuring this out - now I can enable this functionality in all my apps where I'm syncing with Calendar

 

BTW: thinking about headless and services - I would like to be able to get notified if data was deleted from Calendar by user - then I can watch this and correct my database. same for Contacts ...

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner