I try to access the value of my json objects in sap ui5, but the getproperty function cannot access the required data. But, at first, I have created a xsodata file with some service definitions, e.g.
"CUSTOMER_ATTR_G3" as "Customers";
Then I try to get these data in view.js file with the following code:
oModel.loadData("UserInterface_G3/SERVICES/CUSTOMER_ATTR_G3.xsodata/Customers?$select=CUSTOMER_ID,CUSTOMER_DESCRIPTION&$format=json");
When I am using console.log(oModel) I see in the odata section that the values are in the object but I cannot access to them. The following screenshot should show the structure of the object:
I tried for instance:
console.log(oModel.getProperty('/CUSTOMER_DESCRIPTION'));
or
console.log(oModel.getProperty('results/CUSTOMER_DESCRIPTION'));
But I cannot access the values of the object.
Does anybody have an idea on that?
You need to access your Property like that:
You forgot the position inside of your Array. Your Path needs the position, so if you want to get the first entry
CS_0001
then you have to writeresult/0/CUSTOMER_DESCRIPTION
.EDIT:
Actually it depends on your Model, how you have to access the Property. Can you pls show me how you defined your oModel?