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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 13
Registered: ‎04-14-2011
My Device: playbook,SmartPhones
My Carrier: Flex,Blackberry JDE

Need Help With bb10 webworks contacts api

[ Edited ]

I am developing a small application which gets all the contacts stored in mobile as well as  in sim card, I used the webworks contacts api, but the code is not working....Can u help me friends....

 

Following is my html....

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>contacts</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/bbui-min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="local:///chrome/webworks.js"></script>
<script type="text/javascript" src="js/bbui-min.js"></script>
<script type="text/javascript" src="js/getContacts.js"></script>
<script type="text/javascript">

function CallContact()
{	    
	listAllContacts();
		   
}
document.addEventListener('webworksready', GetDeviceInformation());	
function GetDeviceInformation()
{
	
}
</script>
<!--[if gte IE 9]>
  <style type="text/css">
    .gradient {
       filter: none;
    }
  </style>
<![endif]-->
</head>
<body onload="myFunction();">
<div id="wrapper">
	<div  class="loginBtn topOutSpace20" onclick="CallContact();"><span>Sync</span></div>
		<a href="#" class="pageLink topOutSpace35 fl lm-70"  >Reset Activation Code</a>
	<span class="clr"></span>
</div>
</div>
</body>
</html>

 Following is my javascript&colon;getContacts.js

 

function listAllContacts() 
{
	
	var findOptions = {};    
    
    contacts.find(["name"], findOptions, onFindSuccess, onFindError);
	
}
function onFindSuccess(results) {
    alert("Found " + results.length + " contacts in total");
}

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

 

 

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Need Help With bb10 webworks contacts api

Please clarify what you mean by "code is not working":

  • Expected behavior?
  • Actual behavior?
  • Errors?

 

Have you seen this sample app that demonstrates how to use contacts in a BB10 WebWorks app?

 

https://github.com/blackberry/BB10-WebWorks-Community-Samples/tree/master/pimcontacts

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Contributor
Posts: 13
Registered: ‎04-14-2011
My Device: playbook,SmartPhones
My Carrier: Flex,Blackberry JDE

Re: Need Help With bb10 webworks contacts api

I Used the code demonstrated in listAllContacts() function

https://github.com/blackberry/BB10-WebWorks-Community-Samples/tree/master/pimcontacts

 

 

function listAllContacts() 
{
	/* Create a blank ContactFindOptions object. */
findOptions = new blackberry.pim.contacts.ContactFindOptions();

/* The field(s) we will filter our returned Contacts on. */
findOptions.filter = [
{fieldName: blackberry.pim.contacts.ContactFindOptions.SEARCH_FIELD_FAMILY_NAME, fieldValue: _contacts.filter.value}
];

/* The sort order. */
findOptions.sort = [
{fieldName: blackberry.pim.contacts.ContactFindOptions.SORT_FIELD_GIVEN_NAME, desc: true},
{fieldName: blackberry.pim.contacts.ContactFindOptions.SORT_FIELD_FAMILY_NAME, desc: false}
];

/* Number of contacts to return. */
findOptions.limit = 5;

/* Return only favorite contacts? */
findOptions.favorite = false;

/* Here we supply the variables we just initialized and invoke our call to find. */
blackberry.pim.contacts.find(contactFields, findOptions, onFindSuccess, onFindError);
}

  In the above code, The contacts are returned only when the SEARCH_FIELD_FAMILY_NAME value exactly matches in the contacts stored in the simulator.Otherwise it returns 0 contacts.But i want to get all the contacts, so i did not give anything in findoptions.But nothing seems work.

New Contributor
Posts: 5
Registered: ‎08-11-2013
My Device: simulator
My Carrier: TC

Re: Need Help With bb10 webworks contacts api

I am having the same issue.

But I am receiving a maximum of 20 contacts with findOptions empty. 

Contributor
Posts: 13
Registered: ‎04-14-2011
My Device: playbook,SmartPhones
My Carrier: Flex,Blackberry JDE

Re: Need Help With bb10 webworks contacts api

I think it is better to move to the native sdk....But still we need your help friends.

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Need Help With bb10 webworks contacts api

Spoke with our dev team who provided the following feedback:

 

"From what I see in source, the default of –1 should return all contacts. The sample in docs does limit to 20.

 

https://github.com/blackberry/BB10-WebWorks-Framework/blob/master/ext/pim.contacts/ContactFindOption...

 

https://developer.blackberry.com/html5/apis/blackberry.pim.contacts.html

 

I suggest trying the sample code:  listAllContactsWithEmptyFindOptions()"

 

 

So can I suggest you try it with -1 and see if you get the expected > than 20 results?

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
New Contributor
Posts: 5
Registered: ‎08-11-2013
My Device: simulator
My Carrier: TC

Re: Need Help With bb10 webworks contacts api

[ Edited ]

I did try with -1 and didn't receive any contacts. So I tried a limit of 1000 and got all my contacts of 183. 

This worked on my simulator with OS 10.1.x.x and when I moved over to a actual device with OS 10.0... , it returned max 20.

 

Is there a difference between BB OS 10.0 & 10.1 when it comes to webworks?

 

I did try the listAllContactsWithEmptyFindOptions with the empty findOptions and it returned 20 contacts.

Developer
Posts: 68
Registered: ‎01-23-2012
My Device: Z10, Q10 & Playbook 64Gb

Re: Need Help With bb10 webworks contacts api

any update on this issue? i tried: listAllContactsWithEmptyFindOptions() and it also returns 20 contact.
New Contributor
Posts: 5
Registered: ‎08-11-2013
My Device: simulator
My Carrier: TC

Re: Need Help With bb10 webworks contacts api

What worked for me is setting the limit to value of 1000. 

A limit of -1 or empty findOptions just simply returned max 20 contacts.

 

Take a look at populateContacts function:

https://github.com/blackberry/BB10-WebWorks-Community-Samples/blob/master/pimcontacts/complete/js/co...

 

Just set your limit to value that works for you.

/* Number of contacts to return. */
findOptions.limit = 5;
 
 
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Need Help With bb10 webworks contacts api

Okay, suggest using your own large upper limit for now.  

 

I filed a bug against the issue with using -1 in the findOptions, so its on the dev team's radar

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.