Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

selectedProperty multiple fields

How can I get the contact's name when using selectedProperty?

values.selectedProperty = function(e) {
if (e.property == 'email') {
Ti.API.log(e.label + ": " + e.value);
}
}

how can I not only get the email address, but I also get who the contact is. So i want 'John Smith' and the email address.

— asked November 20th 2010 by B J
  • contact
  • iphone
  • mobile
0 Comments

2 Answers

  • Hi Bryan

    Try the following, quoted from ticket #1001, and let us know if it works:

    Titanium.Contacts.showContacts({
    selectedPerson: function(e) {
        var person = e.person;
        var emails = person.email;
        Ti.API.log(emails); // Display the multivalue format, or...
        for (var label in emails) {
            var emailList = emails[label];
            Ti.API.log(label + ": "+emailList);
        }
    }
    });
    

    Bear in mind that android doesn't support selectedProperty, so if you are using that platform for development, you need to use selectedPerson, as demonstrated in contacts_picker.js: For example,

    values.selectedPerson = function(e) {info.text = e.person.fullName;};
    
    — answered November 20th 2010 by Paul Dowsett
    permalink
    0 Comments
  • Hello,

    If I have two emails or phones with the same label and run a code like the above, the relevant label gets to be assigned with both values separated by a comma. Is there a way to distinguish between them?

    Thanks

    Vassilis

    — answered June 27th 2011 by Dev Team Mobiltron
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.