cancel
Showing results for 
Search instead for 
Did you mean: 

Type error: Cannot read properties of undefined ( reading 'read' )

Former Member
0 Kudos
8,590

Hi Team,

I am facing an issue in my custom UI5 application while reading the data from backend for my Read query -

onInit: function () {

this.oModel = this.getOwnerComponent().getModel();

this.oCustTable = this.getView().byId("idCustTable");

this.oModel.read("/ET_Deal_CustListSet", {

success: function (odata) {

var CustJsonData = new JSONModel(odata.results);

this.getView().setModel(CustJsonData, "ET_CustList");

}

});

},

img-20221208-wa0031.jpg

manifest1.jpgmanifest2.jpgmanifest3.jpgmanifest4.jpg

Please advise.

Regards -

Meenakshi

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos
  • Could you please share the content of your "manifest.appdescr" (or "manifest.json") file from the browser's devtool network tab?
  • What does the browser report if you log this.getOwnerComponent().getManifestEntry("/sap.ui5/models") in that onInit handler?
Former Member
0 Kudos

boghyon.hoffmann

Hello,

The manifest file in the network tab has 200 status code. While, when I logged the query as given by you, I get the following response - img-20221208-wa0033.jpg

Former Member
0 Kudos

boghyon.hoffmann I have included the screenshots of my manifest file in the main section as well.

Accepted Solutions (1)

Accepted Solutions (1)

boghyon
Product and Topic Expert
Product and Topic Expert

Your screenshot "manifest3.jpg" shows the issue: the default model (model declaration with the empty string "" as its name) is not within the /sap.ui5/models section of manifest.json.

Solution: move the default model declaration, same as the "i18n" model declaration, to the section /sap.ui5/models.

___

Please consider developing / maintaining UI5 application projects either within SAP BAS or VSCode with the extension UI5 Language Assistant. That extension would've notified you about the misplaced section.

Answers (4)

Answers (4)

0 Kudos

Please include your default odata model in the model section in manifest.json file

ThorstenHoefer
Active Contributor
0 Kudos

Hi meenakshi.raina,

please debug your code and check the position raising the error.
Perhaps you see the error line in the JavaScript console?

It could be the case that the success methode doesn't have access to this.getView().

In this case you can change your code to:

or

success: function (odata) {
var CustJsonData = new JSONModel(odata.results);
this.getView().setModel(CustJsonData, "ET_CustList");
}.bind(this)
});
var that = this;
....
success: function (odata) {
var CustJsonData = new JSONModel(odata.results);
that.getView().setModel(CustJsonData, "ET_CustList");
}
});
ThorstenHoefer
Active Contributor
0 Kudos

Hi,

did you included the section "models" to the manifest file?

"models": {
"": {
"dataSource": "mainService",
"settings": {
"defaultBindingMode": "TwoWay",
"defaultCountMode": "Inline",
"refreshAfterChange": false
}
}
Former Member
0 Kudos

Hello,

Yes, I have written this part.

manifest3.jpg

AshishAnand
Advisor
Advisor
0 Kudos

Hi meenakshi.raina,

This could be because this.getOwnerComponent().getModel() is returning undefined. Kindly check if it helps 🙂

Thanks and Regards

Ashish

Former Member
0 Kudos

Hi ashish

Yes, that's correct. But I have defined my service in the manifest file. img-20221208-wa0032.jpg

Do I need to do more?