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.
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;};
-
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