Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How can I change data in OData v4 model programmatically?

Former Member
0 Likes
895

I have a named OData version 4 source in my SAPUI5 application. I need to manipulate object data in a button click event handler like this:

var oContext = evt.getSource().getBindingContext("dsName"); // works

var sPath = oContext.getPath() + "/myPropertyName";

// Approach 1 for setting value to true:

oContext.getModel().setProperty(sPath, true); // not working

// Approach 2:

var item = evt.getSource().getBindingContext("dsName").getObject();

item.myProperty = true; // not working

The only way I managed to change the property value was by two-way-binding it to a control (check input). Can someone tell me if and how it is possible to update OData v4 models in code?

I have a named OData version 4 source in my SAPUI5 application. I need to manipulate object data in a button click event handler like this:

var oContext = evt.getSource().getBindingContext("dsName"); // works

var sPath = oContext.getPath() + "/myPropertyName";

// Approach 1 for setting value to true:

oContext.getModel().setProperty(sPath, true); // not working

// Approach 2:

var item = evt.getSource().getBindingContext("dsName").getObject();

item.myProperty = true; // not working

The only way I managed to change the property value was by two-way-binding it to a control (check input). Can someone tell me if and how it is possible to update OData v4 models in code?

0 REPLIES 0