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
Developer
Posts: 554
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor
Accepted Solution

Add Contact OS10

[ Edited ]

Edited by oros: Moved code to code blocks for readablity.

 

Took the following sample from the API doc

 

function onSaveSuccess(contact) 
 {
    //console.log("Contact with id=" + contact.id + " is saved!");
    alert("Contact with id=" + contact.id + " is saved!");
 }

function onSaveError(error) {
   // console.log("Error saving contact: " + error.code);
   
   alert("Error saving contact: " + error.code);
}

function createContact() {
    var contacts = blackberry.pim.contacts,
        ContactField = contacts.ContactField,
        name = {},
        workPhone = { type: ContactField.WORK, value: "0046856400500" },
        workEmail = { type: ContactField.WORK, value: "ingvar@nova-data.se" },
        homeEmail = { type: ContactField.HOME, value: "ingvar.engelbrecht@gmail.com" },
        contact;
        
    name.familyName = "Engelbrecht";
    name.givenName = "Ingvar";
    contact = contacts.create({
         "displayName": "ingvar_e",
         "name": name,
         "phoneNumbers": [workPhone],
         "emails": [workEmail, homeEmail]
    });
    contact.save(onSaveSuccess, onSaveError);
}

added to config

 

    <feature id="blackberry.pim.contacts"/>
 
    <rim:permissions>  
        <rim:permit>read_geolocation</rim:permit>
        <rim:permit>access_shared</rim:permit>
        <rim:permit>access_pimdomain_contacts</rim:permit>
    </rim:permissions> 

 

got message:

 

Uncaught type error: cannot read property 'contact' from undefined

 

additional

When I first looked for information I ended up on the page below that contained no information at all but looked exactly like the normal API documentation. Please remove!

 

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

 

 

 

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Highlighted
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Add Contact OS10

Can you confirm which line of code is throwing that error?

 

Based on the wording, I would expect something along the lines of someVariable.contact to be throwing the error, but I can not see any such usage in the posted code.


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.
Developer
Posts: 554
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Add Contact OS10

The error message in the ripple log is underneath this statement

 

var contacts = blackberry.pim.contacts,
If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Add Contact OS10

[ Edited ]

Is this issue happening on the device or within Ripple? If Ripple, please note that blackberry.pim is not actually defined / available there.

 

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

 

EDIT: Note that your documentation link is for the BBOS PIM APIs: https://developer.blackberry.com/html5/apis/blackberry.pim.contact.html

 

You will need to test on a Simulator / physical device. If this is not in Ripple, if you execute the following three lines of code prior to the identified error line, can you please confirm the output?

 

console.log(blackberry);
console.log(blackberry.pim);
console.log(blackberry.pim.contacts);

I am expecting that you will get:

1) An object.

2) undefind.

3) An error thrown simliar to the original.

 

If that's the case, the issue will be stemming from how the API is being included (and I'll have a few more questions.)


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.
Developer
Posts: 554
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Add Contact OS10

Its ripple.

will test on simulator when I have got the unzip working on the simulator.

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-