Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Getting property value from oJsonModel

Hi, this is my code:

var sServiceUrl = "http://<irrelevantAddress>/sap/opu/odata/sap/<irrelevantServiceName>";

  var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);"/EmployeeSet('123')", {


  success: function(oData, response) {



  failed: function(oData, response) {

       alert("Failed to get Form details from service!");



alert("EmpForename: " + oJsonModel.getProperty("/EmpForename"));

so, I want to get Employee from the oModel by pressing on a button. the oJsonModel.getProperty("/EmpForename") returns the right value after i press the according button the second time. First time i press the button it returns undefined. Why?

Second, i tried using sap.ui.getCore().getModel(). But what if i have many models. I tried different approaches from scn and other places for setting id or names for the models but i always get undefined. That is why I just wanted to use oJsonModel and get values from there but that didnt give me much aswell.

So I would like to know why is oJsonModel.getProperty("/propertyName") doesnt return the right value the first time i try to set oData, or what is the easiest way to use models by their names or ids (would be cool if without the binding thingy because im not familiar with bindings).

Sorry for messy English and thanks

Former Member

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question