SAP UI5 oDataModel setProperty not working

Jun 02, 2017 at 01:26 PM


avatar image
Former Member


I am not able to set the value of a field in the oData model using setProperty, I am getting "false" as return value.

I have used a "CRUD Master-Detail Application" . From the Detail view, I navigate to Edit view. I have Input fields and a radio button on the Edit page. If I change the value of the Input field, the model is getting updated. For the radio button, I have a function for "select" property defined for RadioButtonGroup. I am getting the value(based on the selectedIndex) but when I am using setProperty on the oData Model, I am getting a false as a return.

In the controller for the Edit view, in "OnInit" function, I have a call for "_onEdit" function. I am using to bind the data to the view.

oPath = "/ItemsEntitySet(Index)" (Index selected on the Detail View)


path: oPath


On Radio button selection, I am getting the selectedIndex and the value corresponding to the index and trying to set the value back to the oData Model(200 is the value to be set for the field in oData Model Items Entity. And oResult is "false".

var oResult = this.getModel().setProperty("/ItemsEntityDetail/Index/Field", "200");

Please let me know what I am missing. Other Input fields on the Edit view are automatically getting updated when their values are changed.



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jun Wu Jun 02, 2017 at 01:48 PM

how about this?


this.getModel().setProperty(path+"/Field", "200");

10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jun 02, 2017 at 02:03 PM

Hi Jun,

Thank you for the quick reply. I tried with your suggestion and it still didn't work.

Show 10 Share
10 |10000 characters needed characters left characters exceeded

show me your code, are u using jsonmodel or odatamodel?

Former Member

It is oData Model.

var oPath1 ="/BankDetailSet("+index+")";

var oSet = this.getModel().setProperty(oPath1+"/Bkont", "02");

Do you want me to upload the project file?


var oPath1 ="/BankDetailSet('"+index+"')";

small change, surround the index with '

Former Member
Jun Wu

No change :(

I tried even with the Navigation name "BankDataNav" that I used in Detail view.


check in dev tool

give me a screenshot of your model object(with odata attribute expanded)

Former Member
Jun Wu


It looks like the issue is in the "if block". If I use the setProperty outside the if block, I am able to set the model.

Inside the "if block", my model is "undefined". I tried to fetch the model again inside the if block to rule out scope issues, but no luck. Please see varaibles oSet and oSet2 doing the same.. one outside and another inside the "if block". oSet is true and oSet2 is undefined. Can you please help me find what I am missing with the model?

ss2.jpg (252.7 kB)
Former Member
Former Member

I changed the comparison to "if (index == '1')"and now it works. I still do not know why "if (index === '1')" is an issue.

Show more comments
Former Member

Master View

<List id="list" items="{ path: '/BankTypeSet', sorter: { path: 'Stext', descending: false }, groupHeaderFactory: '.createGroupHeader' }" busyIndicatorDelay="{masterView>/delay}" noDataText="{masterView>/noDataText}" mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}" growing="true" growingScrollToLoad="true" updateFinished="onUpdateFinished" selectionChange="onSelectionChange">


<Toolbar active="true" id="filterBar" visible="{masterView>/isFilterBarVisible}" press="onOpenViewSettings">

<Title id="filterBarLabel" text="{masterView>/filterBarLabel}"/>

</Toolbar> </infoToolbar>


<ObjectListItem type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}" press="onSelectionChange" title="{Stext}"></ObjectListItem>



Detail View

<List id="employeeList" items="{BankDataNav}">


<ObjectListItem title="Bank Name: {Banka}" iconDensityAware="false" number="{Bankn}">


<ObjectAttribute title="{ path: 'Begda', type: 'sap.ui.model.type.Date', formatOptions: { style: 'medium', UTC: true } }" text="{ path: 'Endda', type: 'sap.ui.model.type.Date', formatOptions: { style: 'medium', UTC: true } }"/>

<ObjectAttribute text="Bank Key: {Bankl} "/>

<ObjectAttribute title="Bank Control Key" text="{path: 'Bkont', formatter: '.conv2Text' }"/>

<ObjectAttribute title="Payment Method" text="{path: 'Zlsch', formatter: '.conv2Text' }"/>





Edit View

<f:SimpleForm id="SF_Id" maxContainerCols="2" layout="ResponsiveGridLayout" title="Edit : {Banka}" minWidth="1024" columnsL="1" columnsM="1" editable="true" emptySpanL="4" emptySpanM="4" labelSpanL="3" labelSpanM="3">


<Label text="Valid from" required="true"/>

<DatePicker name="Begda" value="{ path: 'Begda', type: 'sap.ui.model.type.Date', formatOptions: { style: 'medium', UTC: true, maxLength:15}}" id="Begda_id" enabled="{= ${viewModel>/mode} === 'edit'? true: false}" visible="true"/>

<Label text="Bank key number" required="true"/>

<Input name="Bankl" id="Bankl_id" valueLiveUpdate="true" liveChange="_validateSaveEnablement" enabled="{= ${viewModel>/mode} === 'edit'? true: false}" visible="true" value="{Bankl}"/>

<Label text="Bank account" required="true"/>

<Input name="Bankn" id="Bankn_id" valueLiveUpdate="true" liveChange="_validateSaveEnablement" enabled="{= ${viewModel>/mode} === 'edit'? true: false}" visible="true" value="{Bankn}"/>

<Label text="Account type" required="true"/>

<RadioButtonGroup select="onSelectRadio" columns="2" id="RBG_Id">


<RadioButton id="RB1-1" text="Checking account"/>

<RadioButton id="RB1-2" text="Savings account"/>





Skip to Content