SAPUI5GUY
SAPUI5GUY

Reputation: 71

OData Model not loaded?

I am using an OData model in my SAP UI5 application. I do the following:

var oView = this.getView();
this._oModel = oView.getModel();

which I thought loaded the model and allowed me to access whatever I needed to inside the model. However whenever I try to get a property using getProperty(path) it returns undefined. I know the path is correct because I used it elsewhere in my application and it worked okay. The model I am using is named "metadata.xml" if that helps.

Upvotes: 0

Views: 659

Answers (1)

Developer
Developer

Reputation: 361

If you read the documentation provided by SAP talking about OData services (I assume v2), you might find your answer there. Since you are using getProperty(), "you can only access single entities and properties with these methods. To access entity sets, you can get the binding contexts of all read entities via a list binding." Therefore you may want to a read() of the entity set first and then use the results of this read to access whatever property you want.

Link to doc: https://sapui5.hana.ondemand.com/#docs/guide/6c47b2b39db9404582994070ec3d57a2.html

Upvotes: 1

Related Questions