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
Developer
Posts: 28
Registered: ‎09-15-2009
My Device: Not Specified
Accepted Solution

Setting calendar Event "endTime" not working

[ Edited ]

Hi All,

 

I  am trying to invoke the calendar wtih target 'sys.pim.calendar.viewer.eventcreate'.

I could set the subject & start time using "subject" & "startTime" fields, but I am unable to set the "endTime" for the calendar event. Event is always opened with endTime as current Date time and if try to 'Save' it gives error as "End time must be after the start time"

 

Is there any different key for setting end time of event ?

To be more specific I want to set the Calendar event for some future date.

 

Reffering to this link; http://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/calendar.ht...

 

Regards,

Abhay

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Setting calendar Event "endTime" not working

some time ago I also had trouble with this

 

now I'm cretaing the Event using CalendarService from C++

 

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 28
Registered: ‎09-15-2009
My Device: Not Specified

Re: Setting calendar Event "endTime" not working

Thanks ekke for the reply.

 

I went through the CalenderService APIs & looks like those are for directly creating or updating calender event.

 

I missed to mention in original thread that, I want to open the calendar from my application with event subject & start + end time pre-populated. User can chose to 'save' or 'cancel' the event.

 

Is there any way I can achieve thise using the CalenderService?

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Setting calendar Event "endTime" not working

only with some tricks

 

1. create the event using CalendarService

2. open this event using Invokation as CARD

3. test response from ChildCardDone

   just tested: if user did Cancel you get reason "closed" and data ""

  if user set save: you get also reason "closed" but data has some content

  so you can test if data is empty and delete the event from CalendarService

 

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 28
Registered: ‎09-15-2009
My Device: Not Specified

Re: Setting calendar Event "endTime" not working

Hi ekke, 

Can you provide the code snippet ....  how can we open the CalendarEvent using Card Invocation framework.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Setting calendar Event "endTime" not working

something like this

InvokeRequest request;
	request.setMimeType("text/calendar");
	request.setTarget("sys.pim.calendar.viewer.eventcreate");
	request.setAction("bb.calendar.EDIT");
	QVariantMap map = QVariantMap();
	map["accountId"] = accountId;
	map["eventId"] = eventId;
	map["folder"] = folderId;
	map["startTime"] = startTime;
	request.setData(bb::PpsObject::encode(map));
	mInvokeManager->invoke(request);

 

void ApplicationUI::childCardDone(
		const bb::system::CardDoneMessage &doneMessage) {
	qDebug() << "reason" << doneMessage.reason();
	qDebug() << "data&colon; " << doneMessage.data();
}

 

from your created event you get the folderId() and startTime().toString()

 

hope you got the idea HowTo solve it

 

Most of my apps have connected Calendar and so I'm always using same pattern and forgot the details ;-)

- if some info is missing please ask again

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 28
Registered: ‎09-15-2009
My Device: Not Specified

Re: Setting calendar Event "endTime" not working

Again thanks for the reply.

But this part I am able to achieve, as I mentioned in my question "I want to set the endTime for the CalendarEvent".

 

I observed that even if I set ;

map["endTime"] = endTime;

 

the event considers current DateTime as end date.

Any help on this Smiley Happy ???

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Setting calendar Event "endTime" not working

should be no problem to set start and end time

 

stripped some parts from the code below (esp my Timezone Offset handling) but should help you

 

my usecase was to create an Event from a scheduled Session at a Conference where I have a date and start time and time of session

 

int ConferenceCalendar::addSessionEvent(Session* session, const int accountId,
		const int folderId, const bool noCollisionDetection) {
	CalendarEvent sessionEvent;
	sessionEvent.setAccountId(accountId);
	sessionEvent.setFolderId(folderId);
	sessionEvent.setSubject("C2G-JAX: " + session->title());
	sessionEvent.setBusyStatus(BusyStatus::Tentative);
	sessionEvent.setReminder(15);
	sessionEvent.setLocation(...);
	
	sessionEvent.setBody(...);
	
	sessionEvent.setTimezone("Europe/Amsterdam");
	int offsetDiffInSeconds = 0;
	QString dt;
	...
	dt = session->sessiondate();
	// 11:50
	dt += "T";
	dt += session->sessionstart();
	dt += ":00";
	
	QDateTime qdt = QDateTime::fromString(dt, Qt::ISODate);
	sessionEvent.setStartTime(qdt);
	dt = session->sessiondate();
	dt += "T";
	dt += session->sessionend();
	dt += ":00";
	qdt = QDateTime::fromString(dt, Qt::ISODate);
	sessionEvent.setEndTime(qdt);
	
	// create the event
	mCalendarService.createEvent(sessionEvent);
	qDebug() << "session: " << session->id() << " account: " << accountId
			<< " folder: " << folderId;
	qDebug() << "event CREATED with id" << sessionEvent.id();

	if (sessionEvent.id() > 0) {
		toast->setBody(tr("Calendar Event successfully created :)"));
		toast->show();
		return sessionEvent.id();
	} else {
		toast->setBody(tr("Calendar Event was not created :("));
		toast->show();
		return NO_CALENDAR_EVENT_CREATED;
	}
}

 

hope it helps

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 28
Registered: ‎09-15-2009
My Device: Not Specified

Re: Setting calendar Event "endTime" not working

For me setting the 'endTime' does not work.

 

bb::system::InvokeRequest req;
req.setMimeType("text/calendar");
req.setTarget("sys.pim.calendar.viewer.eventcreate");
req.setAction("bb.calendar.CREATE");
QVariantMap data = QVariantMap();

data["subject"] = eventSubject ;

data["startTime"] = startTime; // in format '2014-05-30 10:30:00

data["endTime"] = endTime // in format '2014-05-30 11:30:00
req.setData(PpsObject::encode(data));
m_invokeManager->invoke(req);

 

This opens the Calendar & shows the event Subject & startTime, but end time is always the current DateTime.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Setting calendar Event "endTime" not working

hmmmm

 

I thought we already discussed that you have to create the event with CalendarService,

because it doesn't work with Invokation where you only can set the start time

!

then you can use Invoke to present a Card to your user

then if user cancels remove the event - otherwise all is ok

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner