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

Java Development

Reply
New Developer
equis_dos
Posts: 4
Registered: ‎09-06-2008
My Device: Not Specified

Adding Phone number to contact problem

[ Edited ]

If I use the below code with a contact that has more the 4 phone numbers a FieldFullException is thrown even though MaxValues reports that we are allowed 8.

 

 

contact.addString(Contact.TEL, BlackBerryContact.ATTR_XXXX, _phone.getText());


 

I am using the 4.5 JDE.

 

Cheers,

 

Christoper Walters

Message Edited by equis_dos on 09-07-2008 12:33 AM
BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Adding Phone number to contact problem

If the same sting value has already been added, you should use the setString method instead of addString to modify it because the same field can not be added more than once.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
equis_dos
Posts: 4
Registered: ‎09-06-2008
My Device: Not Specified

Re: Adding Phone number to contact problem

Mark,

 

The field has not already been set.  If I try to do it with a setString (insted of add an exception is also thrown).   See example code below.

 

A contact was chosen that did not have a ATTR_WORK number associated with it.

 

try { BlackBerryContactList contactList = (BlackBerryContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE); PIMItem pimItem = contactList.choose(); if (pimItem != null) { contact = (BlackBerryContact)pimItem; int fieldsWithData[] = contact.getFields(); int fieldCount, atrCount; for ( fieldCount = 0; fieldCount < fieldsWithData.length; ++fieldCount) { //Populate the appropriate BasicEditfield. switch (fieldsWithData[fieldCount]) { case BlackBerryContact.TEL: for (atrCount = 0; atrCount < contact.countValues(BlackBerryContact.TEL); ++atrCount) { switch(contact.getAttributes(BlackBerryContact.TEL, atrCount)) { case BlackBerryContact.ATTR_WORK: System.out.println("WORK = " + contact.getString(BlackBerryContact.TEL, atrCount)); break; case BlackBerryContact.ATTR_WORK2: System.out.println("WORK2 = " + contact.getString(BlackBerryContact.TEL, atrCount)); break; case BlackBerryContact.ATTR_HOME: System.out.println("HOME = " + contact.getString(BlackBerryContact.TEL, atrCount)); break; case BlackBerryContact.ATTR_HOME2: System.out.println("HOME2 = " + contact.getString(BlackBerryContact.TEL, atrCount)); break; case BlackBerryContact.ATTR_MOBILE: System.out.println("MOBILE = " + contact.getString(BlackBerryContact.TEL, atrCount)); break; } } break; } } System.out.println("MAX Allowed = " + contactList.maxValues(Contact.TEL)); System.out.println("Current Count = " + contact.countValues(Contact.TEL)); contact.addString(Contact.TEL, BlackBerryContact.ATTR_WORK, _phone.getText()); System.out.println("After WORK Current Count = " + contact.countValues(Contact.TEL)); } } catch (PIMException e) { }

 

 

 

 

 

System Output.

WORK2  = 123-123-1234
HOME  = 234-234-2345
HOME2  = 234-234-2346
MOBILE  = 345-345-3455
MAX Allowed   = 8
Current Count = 4

 

a fullfieldexception is thrown at this point.

 

 

 

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Adding Phone number to contact problem

Thanks for the sample code, I was able to reproduce this using the BlackBerry Simulators included in the BlackBerry JDE version 4.5.0 and 4.6.0.  The problem is caused by an issue with the BlackBerry handheld software.  I have verified that this is fixed in BlackBerry handheld software version 4.6.0.148.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
equis_dos
Posts: 4
Registered: ‎09-06-2008
My Device: Not Specified

Re: Adding Phone number to contact problem

Mark,

 

 

Can you think of a workaround?

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Adding Phone number to contact problem

The problem occurs with the update.  You could create a fresh new BlackBerryContact with your required updates and deleting the existing one.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
fbouchedid
Posts: 11
Registered: ‎08-19-2008
My Device: 9700 Bold

Re: Adding Phone number to contact problem

Mark,

Do you know if there is going to be an update for 4.5.0 that fixes this issue?

Thanks

Fares Bouchedid
Fares Bouchedid
Software Engineer
Notify Technology Corporation
www.notifycorp.com