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:

try {
var dataQuery = new Backendless.DataQuery();
dataQuery.condition = "name = '"+ document.getElementById('iname').value+"'";

var obj = Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).find(dataQuery);


obj.data.name = 'PD';


Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).save(obj);


} catch(e){
createPopup(e.message, 'error')
}

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:

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

HI,

i tried this

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

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

its working with this code:


var dataQuery = new Backendless.DataQuery();
	dataQuery.condition = "name = '"+ document.getElementById('iname').value+"'";
var da=Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).find(dataQuery);


var obj = da.data[0];
obj.name = 'PD';
delete obj['_private_relations'];
delete obj['_private_geoRelations'];
delete obj['_private_dates'];
Backendless.Persistence.of($rootScope.Classes[$rootScope.table]).save(obj);

thank you