Unable to retrieve value for field-property 'contacts' during saving user object with relation prop

Hi,
I am getting an error “Unable to retrieve value for field/property ‘contacts’” when i am attempting to save my user object (BackendlessUser) which contains a one-to-many relation. However, when i go to the backendless database dashboard, all data are saved with relations linked.
Below are the relationship:
Backendless User
http://support.backendless.com/public/attachments/6dc620c1b8f1908fa0343338baf2f4f1.png</img>
PhoneBook
http://support.backendless.com/public/attachments/80749b5a3fe6784b01eb353b12ae7843.png</img>
Contact
http://support.backendless.com/public/attachments/6badb6151c35fae0cf61f8c708df356f.png</img>
Here are something that i’ve tried:

  1. Use the latest backendless.jar - still same
  2. Use both synchronous and asynchronous method - still same
  3. Remove the one-to-many “contacts” from PhoneBook - get the same error but changed from ‘contacts’ to ‘owner’
  4. Remove both one-to-many “contacts” and one-to-one “owner” from PhoneBook - works fine
  5. Save the PhoneBook object only - works fine
    This is very annoying since I can’t really save the basic user object. Please give some advice. Thanks.
    Here is my code, a very simple one:
Runnable runnable = new Runnable() {
 public void run() {
 final BackendlessUser user = new BackendlessUser();
 final String userEmail = "xxxfillInYourEmailHerexxx";
 final String userPassword = "test1234";
 user.setEmail(userEmail);
 user.setPassword(userPassword);
 //synchronous api call is not allowed in the main UI thread, you must use a different thread to run this.
 try {
 Backendless.UserService.register(user);
 }
 catch(BackendlessException exp)
 {
 Log.d("Backend error: ", exp.toString());
 }
 try {
 BackendlessUser backendlessUser = Backendless.UserService.login(userEmail, userPassword, true);
 Backendless.UserService.setCurrentUser(backendlessUser);
 }
 catch(BackendlessException exp)
 {
 Log.d("Backend error: ", exp.getMessage());
 }
 Log.d("Successfully login: ", Backendless.UserService.CurrentUser().getEmail());
 Address address = new Address();
 address.setStreet("TN 55");
 address.setCity("Lynchburg");
 address.setState("Tennessee");
 Contact owner = new Contact();
 owner.setName("Jack Daniels");
 owner.setAge(147);
 owner.setPhone("777-777-777");
 owner.setTitle("Favorites");
 owner.setAddress(address);
 Contact contact2 = new Contact();
 contact2.setName("Jack2");
 contact2.setAge(5);
 contact2.setPhone("777-777-777");
 contact2.setTitle("Favorites");
 contact2.setAddress(address);
 Contact contact3 = new Contact();
 contact3.setName("Jack3");
 contact3.setAge(10);
 contact3.setPhone("777-777-777");
 contact3.setTitle("Favorites");
 contact3.setAddress(address);
 Contact contact4 = new Contact();
 contact4.setName("Jack4");
 contact4.setAge(58);
 contact4.setPhone("777-777-777");
 contact4.setTitle("Favorites");
 contact4.setAddress(address);
 Contact contact5 = new Contact();
 contact5.setName("Jack5");
 contact5.setAge(500);
 contact5.setPhone("777-777-777");
 contact5.setTitle("Favorites");
 contact5.setAddress(address);
 List<Contact> contactList1 = new ArrayList<Contact>();
 contactList1.add(owner);
 contactList1.add(contact2);
 contactList1.add(contact3);
 List<Contact> contactList2 = new ArrayList<Contact>();
 contactList2.add(contact4);
 contactList2.add(contact5);
 List<Contact> contactList3 = new ArrayList<Contact>();
 contactList3.add(owner);
 contactList3.add(contact3);
 contactList3.add(contact5);
 PhoneBook phoneBook = new PhoneBook();
 phoneBook.setOwner(owner);
 phoneBook.setContacts(contactList2);
 phoneBook.setIsFavourite(true);
 PhoneBook phoneBook2 = new PhoneBook();
 phoneBook2.setOwner(contact5);
 phoneBook2.setContacts(contactList1);
 phoneBook2.setIsFavourite(true);
 PhoneBook phoneBook3 = new PhoneBook();
 phoneBook3.setOwner(contact2);
 phoneBook3.setContacts(contactList3);
 phoneBook3.setIsFavourite(false);
 final List<PhoneBook> phoneBookList = new ArrayList<PhoneBook>();
 phoneBookList.add(phoneBook);
 phoneBookList.add(phoneBook2);
 phoneBookList.add(phoneBook3);
 BackendlessUser currentUser = Backendless.UserService.CurrentUser();
 currentUser.setProperty("PhoneBookList", phoneBookList);
 try {
 BackendlessUser savedUser = Backendless.Persistence.save(currentUser);
 // user has been updated
 Object[] objects = (Object[]) savedUser.getProperty("PhoneBookList");
 if (objects.length > 0) {
 PhoneBook[] userPhoneBookList = (PhoneBook[]) objects;
 for (PhoneBook phonebook : userPhoneBookList)
 Log.d("response: ", phonebook.getOwner().getName());
 }
 }
 catch(BackendlessException exp)
 {
 Log.d("Backend error: ", exp.getMessage());
 }
 }
};
Thread mythread = new Thread(runnable);
mythread.start();

6dc620c1b8f1908fa0343338baf2f4f1.png

6badb6151c35fae0cf61f8c708df356f.png

Hi,

Can you please prepare the sample app which uses your application and would reproduce the problem?

Hi,

Thanks for your reply. I’ve sent the sample code to your support email. Or you may get the sample code here: https://drive.google.com/file/d/0B_6LgbMyNiYwNURFQTctQkxGTmM/view?usp=sharing

hi,

May i know what is the status of this issue? Is it reproduceable?

Hi,

Internal ticket with id BKNDLSS-12929 has been created for this issue.

Regards,

Denys

Hey buddy… I just had the same problem. And solved it by using
Backendless.UserService.update(user);
instead of
Backendless.Persistance.save(user);
Not sure what the difference is but give it a try. :slight_smile:

Hi Darrel,
I would also recommend this workaround.
Artur

I’ve had a similar error, but I’ve tried to update my object instead of the backendless user.
http://support.backendless.com/t/unable-to-retrieve-value-for-field-property-for-backendlessuser-object

We have made an update. Please, try once again.