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

Adobe AIR Development

Reply
Developer
Posts: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Creating Calender Event

I want to test creating event in calender using the following code:

var str:String = "";
	str +=  "accountId:n:1234\n";
	str +=  "folderId:n:123\n";
	str += "participants:json:"+JSON.stringify
	    (["email1@site.com", "email2@site.com" ]) + "\n";
	str +=  "subject::I am a subject\n";
	str +=  "body::I am the body\n";
	str +=  "startTime::" + "Fri Jan 10 13:00:00 2014" + "\n";
	str +=  "duration:n:" + 30 + "\n";
	var ba:ByteArray = new ByteArray();
	ba.writeUTFBytes(str);
	var request:InvokeRequest = new InvokeRequest();
	request.action = "bb.action.CREATE";
	request.target = 'sys.pim.calendar.viewer.eventcreate';
	request.mimeType = 'text/calendar';
	request.data = ba;

Can anyone help me to understand what is accountId:n:1234 and folderId:n:123? What should I mention there?

When I tried the exact code, nothing happens on simulator!

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Creating Calender Event

Try it without it. I dont recall needing those when I created a calendar event.
Trusted Contributor
Posts: 101
Registered: ‎03-04-2011
My Device: BB10-Dev Alpha
My Carrier: -

Re: Creating Calender Event

I tried without it, but it is not working. I even have added the following permission to bar descriptor file.

<permission>access_pimdomain_calendars</permission>

 

I am testing on Simulator.

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Creating Calender Event

That is only needed for direct APIs, not invocation. Send me a PM to remind me to look at the code I have that does this. Wont be able to check till tomorrow, unless someone else has the solution.
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Creating Calender Event

This is what I have:

var duration : int = 120; // minutes
if( info.end_time != null )
{
	duration = ( info.end_time.time - info.start_time.time ) / ( 60*1000 );
}

var command : String = '';
command += 'subject::' + info.title + '\n';
				
command += 'location::' + info.venue_name + ': ';
if( info.venue_street != '' )
{
	command += info.venue_street + ', ';
}
command += info.venue_city + ', ' + info.venue_state + '\n';
				
if( info.description != '' )command += 'body::' + info.description +'\n';
command += 'startTime::' + DateUtil.formatBBDateTime( info.start_time ) + '\n';
command += 'duration:n:' + duration + '\n';
				
//trace( 'cmd ' + command );

var data &colon;ByteArray = new ByteArray();
data.writeUTFBytes( command );
				
var request :InvokeRequest = new InvokeRequest();
request.action = "bb.action.CREATE";
request.target = 'sys.pim.calendar.viewer.eventcreate';
request.mimeType = 'text/calendar';
request.data = data;
				
InvokeManager.invokeManager.invoke( request );

 The "info" class is an internal class that contains venue information, but it should be obvious.

 

Date util returns short day of week + ' ' + short month + ' ' + date + ' ' + h:m:s + ' ' + year.

Developer
Posts: 275
Registered: ‎01-21-2013
My Device: BB10 Dev Aplha
My Carrier: -

Re: Creating Calender Event

Thanks!

 

I was using the same code, only missed out on adding the Device ane. It is working fine now.

 

Sangram