Hi,
For update I need odata model right? But I am using a filter on the service url, which is working fine with Json model, when i tried with odata model it's returning error as bed request.
var Model1 = new sap.ui.model.json.JSONModel({ serviceUrl: "../../services/myexp.xsodata/OrderItem?$filter=AUFNR eq "+id }); sap.ui.getCore().setModel(Model1,'myitem'); // working fine // i am using the below code, for update to work var Model1 = new sap.ui.model.odata.v2.ODataModel({ serviceUrl: "../../services/myexp.xsodata/OrderItem?$filter=AUFNR eq "+id }); // returning bed request, also adding $metadata befor the $filter(when reading)
how to ovecome this issue, as I am tring the below code to update
onPressAccept: function(){ // var oTable = sap.ui.getCore().byId("detail1"); var dModel = sap.ui.getCore().getModel("myitem"); //var oSelectedItem = oTable.getSelectedItem(); // var sComponent = oSelectedItem.getBindingContext("myitem").getProperty("ASTNR"); console.log(dModel); var oEntry = {}; oEntry.ASTNR = "Approved"; dModel.update('', oEntry, null, function(){ alert("Update successful"); },function(){ alert("Update failed");}); }
which is not working as dModel is returing a Json model.
Thanks