Hi I am trying to update relational object data in with custom logic. I have an object Persons that has a property that maps to its own table i.e. Person table has contacts relationship property 1:many to Person table, when I find a person I load the relations contacts etc and then I call a method to simply add another user to that list contacts which are persons however I am getting an issue: Caused by: BackendlessException{ code: ‘1007’, message: 'Unable to save object - invalid data type for properties - contacts. You can change the property type in developer console.
’ }
I dont understand why its saying this, all my property types in my model person reflect the same on the backendless console data where my tables are defined.
I cant seem to get this to work and by all sense it should be saving my object with the add person object to my list of contacts
Below is my code:
List<String> relationsRequestingMe = new ArrayList<String>();
relationsRequestingMe.add(“personsRequestingMe”);
relationsRequestingMe.add(“contacts”);
Person personLoggedIn = iDataStore.findById((String) eventArgs.get(“loggedinperson”), relationsRequestingMe);
List<String> relationsImRequesting = new ArrayList<String>();
relationsImRequesting.add(“personsImRequesting”);
relationsImRequesting.add(“contacts”);
Person personOther = iDataStore.findById((String) eventArgs.get(“otherperson”), relationsImRequesting);
for (int i = 0; i < personLoggedIn.getPersonsRequestingMe().size(); i++) {
if (personLoggedIn.getPersonsRequestingMe().get(i).getObjectId().equals(eventArgs.get("otherperson"))) {
personLoggedIn.getPersonsRequestingMe().remove(i);
personLoggedIn.getContacts().add(personOther);
iDataStore.save(personLoggedIn); // Error here, not saving due to BackendlessException
break;
}
}
Im trying to remove a person and add to contacts
Could you please post the Person class and also a screenshot of the schema for class Person. The schema is what you get you get when you click the big red button in the upper right corner of the Data screen.
Regards,
Mark
Hi, attached are my classes and schema screenshots, I added my slot classes encase there something wrong there as well. I’m not declaring all my variables in the code and I’m not sure if its necessary as long as whatever variables i do have are declared in the classes are the same type as in the schema.
Many Thanks!
PersonClass.txt (1.24kB)
slotClass.txt (2.03kB)
Looks good. Just to rule out any previous bugs, could you make sure you’re using the latest backendless.jar? If you pull it from maven, make sure to get version 3.0.8.1. Otherwise, you can download it from our website.
Regards,
Mark
Thanks for the reply, unfortunately the problem still persists, I downloaded the Backendless SDK v3.0.5 for Android released 01.28.2016 and replaced my current backendless.jar and also downloaded the CodeRunner™ v3.0.8 for Java released 02.04.2016 and replaced my lib files with the downloaded versions and replaced the bin folders as well. I’m not to familiar with pulling with maven so wouldn’t know the steps.
Hi, just wondering if there is an update on this ticket? Cheers!
We could not reproduce the problem. If you’d like to package a sample demonstrating the problem, we’ll be happy to look into it. Please keep it simple, we cannot debug entire applications, it needs to be a simple program which focuses strictly on the problem.
Thanks for the reply Mark, I have attached a small sample using a simplified android project and IDEA project, it is very simple, a button that does calls the custom event on the client and a few lines of code on the server that do the removing and adding then saving of the person object. If you need the schema I can get those to you, but it is already described in the model folder, just a contacts, personsRequestingMe and personsImrequesting properties that map to the Persons table as 1:many. I’ve shown the scenario as seen in the screenshot. Hopefully that’s all you need or can provide some more if required.
Sample.zip (27.66MB)
Scenario of two users, one requesting the other as a contact
Here is my schema should you need it for the sample. Many thanks. Leonard
export_2016_02_18_07_06_50.zip (506B)
This issue seems to be resolved now. Thanks