How to add a field to a contact Item?
| Tue, 2006-01-10 03:32 | |
|
Hi guys! Can anyone show how to add a field to a contact item? I am trying to -re-assign the value of the the "job field" or just about any field. If the field has a value, I can replace it. The problem is that if the field is null, i do not know how to add it. Here is my code:
void CphonebkAppUi::ReplaceJob(){ Â Â Â Â Â Â Â Â CPbkContactEngine* yellowpages= CPbkContactEngine::NewL(); Â Â Â Â Â Â Â Â CContactIdArray* id=yellowpages->MatchPhoneNumberL(input,11); Â Â Â Â Â Â Â Â TContactItemId& contactId=(*id)[0]; Â Â Â Â Â Â Â Â CPbkContactItem* contact = yellowpages->OpenContactL(contactId); Â Â Â Â Â Â Â Â TBuf<10> job(_L("driver")); Â Â Â Â Â Â Â Â TPbkContactItemField* field=contact->FindField(EPbkFieldIdJobTitle); Â Â Â Â Â Â Â Â if(field){ Â Â Â Â Â Â Â Â field->TextStorage()->SetTextL(job); Â Â Â Â Â Â Â Â yellowpages->CommitContactL(*contact); Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â else{ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â this means the field is null/unused... Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â how will I add the job field? Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } } ********* input is the phone number and lets just assume that the contactItem was found. thanks in advance! |
|






Forum posts: 21
Forum posts: 78
CPbkFieldInfo* fieldInfo = engine->FieldsInfo().Find( EPbkFieldIdCountry );
contact->AddFieldL( *fieldInfo );
TPbkContactItemField* field = contact->FindField( EPbkFieldIdCountry );
field->TextStorage()->SetTextL( _L("Finland") );
You can check the full compilable example also
Compilable Symbian Code Examples
Forum posts: 114
fields->AppendL(<uid of field you want to add>);