Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

How to create a contact record with address field?  

I create a record, set the name field, number field, and address field, finally,when I call pim_IContacts_AddRecord() to add this record, I got the error code with value 16,telling that there is invalid items.

#define  EBADITEM             16       // Invalid item

When I do not set the address field , it works well. So I think there is something wrong with my code. My code are listed as follows, would someonetell me what's wrong with it, thanks. (By the way, my bmp version is 5.1.00)

ret = pim_IContacts_CreateRecord(pMe->m_BMP_AddrBook,(pim_IContactsRecord**)&pCurRec);  

/*adding name field*/
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Name/1/Type",L"FIRSTNAME");
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Name/1/Value",pNameTemp);
DBGPRINTF("---set name field ret:%d",ret);

/*adding number field*/
ret = pim_IContactsRecord_SetFieldValue(pCurRec,numberTypeStr, L"CELL");	
ret = pim_IContactsRecord_SetFieldValue(pCurRec,numberValueStr, pNumTemp);	
DBGPRINTF("---set cell number field ret:%d",ret);		

/*adding address field*/
//ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Address/1/Type", pim_EFSDBDevice_AddressType_Generic);
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Address/1/Type", pim_EFSDBDevice_AddressType_None);	
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Address/1/Value", pNoteTemp); 
DBGPRINTF("---set address field ret:%d",ret);	

ret = pim_IContacts_AddRecord(pMe->m_BMP_AddrBook,pCurRec);	

 

could not find pim_EFSDBDevice_AddressType_None.
 

does it fails on device or simulator?
 

the below code works for me
 
//pic is instance of pim_AEECLSID_EFSDBDevice

int c_myapp_AddRecord(c_myapp *pMe, pim_IContacts *pic)
{
int nResult;
pim_IContactsRecord* picr = NULL;
// create an empty record

nResult = pim_IContacts_CreateRecord(pic, &picr);
if (AEE_SUCCESS != nResult) {
return nResult;
}
// add a firstname field to the record
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/1/Value", L"SP");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}
// set a type for the name
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/1/Type", L"FIRSTNAME");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}
// add a lastname field to the record
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/2/Value", L"Pratap");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}
// set a type for the name
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/2/Type", L"LASTNAME");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}

nResult = pim_IContactsRecord_SetFieldValue(picr, "Address/1/Value", L"Address Text");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}

nResult = pim_IContactsRecord_SetFieldValue(picr, "Address/1/Type", pim_EFSDBDevice_AddressType_Generic);
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}

// now insert the new contact
nResult = pim_IContacts_AddRecord(pic, picr);
IQI_RELEASEIF(picr);

return nResult;

could not find pim_EFSDBDevice_AddressType_None.
 

does it fails on device or simulator?
 

the below code works for me
 
//pic is instance of pim_AEECLSID_EFSDBDevice

int c_myapp_AddRecord(c_myapp *pMe, pim_IContacts *pic)
{
int nResult;
pim_IContactsRecord* picr = NULL;
// create an empty record

nResult = pim_IContacts_CreateRecord(pic, &picr);
if (AEE_SUCCESS != nResult) {
return nResult;
}
// add a firstname field to the record
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/1/Value", L"SP");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}
// set a type for the name
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/1/Type", L"FIRSTNAME");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}
// add a lastname field to the record
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/2/Value", L"Pratap");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}
// set a type for the name
nResult = pim_IContactsRecord_SetFieldValue(picr, "Name/2/Type", L"LASTNAME");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}

nResult = pim_IContactsRecord_SetFieldValue(picr, "Address/1/Value", L"Address Text");
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}

nResult = pim_IContactsRecord_SetFieldValue(picr, "Address/1/Type", pim_EFSDBDevice_AddressType_Generic);
if (AEE_SUCCESS != nResult) {
IQI_RELEASEIF(picr);
return nResult;
}

// now insert the new contact
nResult = pim_IContacts_AddRecord(pic, picr);
IQI_RELEASEIF(picr);

return nResult;

 
Thanks for your reply.
My code works well on simulator, but does not work on my device. I think it is related to bmp  build version.

 
Thanks for your reply.
My code works well on simulator, but does not work on my device. I think it is related to bmp  build version.

may be, wat device is it?

may be, wat device is it?

Hi liugongquan,
Note that "Address//Type" will ONLY contain one of the pim_EFSDBDevice_Subfield_Address_Type values (defined in pim_EFSDBDevice.bid) i.e.
pim_EFSDBDevice_AddressType_Generic L"GENERIC"
pim_EFSDBDevice_AddressType_Home L"HOME"
pim_EFSDBDevice_AddressType_Business L"BUSINESS"There is no value defined as "pim_EFSDBDevice_AddressType_None" and hence the error as EBADITEM. Not sure if it's defined by you and hence might have worked on simulator.
Regards,
Suresh Kumar S

Hi liugongquan,
Note that "Address//Type" will ONLY contain one of the pim_EFSDBDevice_Subfield_Address_Type values (defined in pim_EFSDBDevice.bid) i.e.
pim_EFSDBDevice_AddressType_Generic L"GENERIC"
pim_EFSDBDevice_AddressType_Home L"HOME"
pim_EFSDBDevice_AddressType_Business L"BUSINESS"There is no value defined as "pim_EFSDBDevice_AddressType_None" and hence the error as EBADITEM. Not sure if it's defined by you and hence might have worked on simulator.
Regards,
Suresh Kumar S

hi Suresh Kumar S
   Thank you very much for you reply, I will try it.
 
  beset regards.

hi Suresh Kumar S
   Thank you very much for you reply, I will try it.
 
  beset regards.