Backendless Support
 
Answered

Updating Specific Record

when i try to update specific record it shows following error:

Saved related data contains inconsistent properties definitions. Please, make sure all related objects contain the same properties set or define all needed properties from console first

My Code is:

  1. try {
  2. var dataQuery = new Backendless.DataQuery();
  3. dataQuery.condition = "name = '"+ document.getElementById('iname').value+"'";
  4. var obj = Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).find(dataQuery);
  5. obj.data.name = 'PD';
  6. Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).save(obj);
  7. } catch(e){
  8. createPopup(e.message, 'error')
  9. }

Leave a Comment

Comments (4)

photo
1

Hi Parth,

"obj.data" returns you an array of results, therefore I suppose "obj.data.name = 'PD'" is not what you really meant. Try this code:

  1. obj.data[0].name = 'PD'

photo
1

HI,

i tried this

  1. obj.data[0].name = 'PD'

It gives same error:

Saved related data contains inconsistent properties definitions. Please, make sure all related objects contain the same properties set or define all needed properties from console first

photo
1

Try inspecting what the "obj" response really contains, this should lead you to the proper way to update and save it.

photo
1

its working with this code:

  1. var dataQuery = new Backendless.DataQuery();
  2. dataQuery.condition = "name = '"+ document.getElementById('iname').value+"'";
  3. var da=Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).find(dataQuery);
  4. var obj = da.data[0];
  5. obj.name = 'PD';
  6. delete obj['_private_relations'];
  7. delete obj['_private_geoRelations'];
  8. delete obj['_private_dates'];
  9. Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).save(obj);

thank you

photo