cancel
Showing results for 
Search instead for 
Did you mean: 

Odata read : Cannot read property 'loaded' of undefined

sdebeaulieu
Participant

Hi,

I've got an issue in a sapui5 application deployed to SAP Cloud Platform and registered to SAP Fiori launchpad.

I've got two data dources defined in my manifest.json : mainService (xsodata), and backendService (odata from OData Provisioning service connected to an ECC backend).

On first application load, data from both services are displayed. When I come back to the launchpad, and I launch again my application, data from backendService is not retrieve.

Code:

this.getModel("backend").read(
	"/*********('" + oResponseUser.*****+ "')", {
		success: fSuccess,
		error: fError
	}
);

Error (only after came back on launchpad and launch app again):

Uncaught (in promise) TypeError: Cannot read property 'loaded' of undefined
    at constructor.y._processRequest (ODataModel-dbg.js:4110)
    at constructor.y.read (ODataModel-dbg.js:4625)
    at f._loadModelUser (App.controller.js?eval:1) ==> Where is my .read() call
    at constructor.b._callListener (EventBus-dbg.js:232)
    at constructor.b.publish (EventBus-dbg.js:219)
    at f._onBindingChange (Detail.controller.js?eval:1)
    at constructor.b.fireEvent (EventProvider-dbg.js:228)
    at constructor.B._fireChange (Binding-dbg.js:277)
    at constructor.O._fireChange (ODataContextBinding-dbg.js:343)
    at ODataContextBinding-dbg.js:101

In my manifest.json :

"dataSources": {
	"mainService": {
		"uri": "/*******/***.xsodata/",
		"type": "OData",
		"settings": {
			"odataVersion": "2.0",
			"localUri": "localService/metadata.xml"
		}
	},
	"backendService": {
		"uri": "/odata/*****/****_SRV;v=1/",
		"type": "OData",
		"settings": {
			"odataVersion": "2.0",
			"localUri": "localService/****_SRV/metadata.xml"
		}
	}
}
"models": {
	"i18n": {
		"type": "sap.ui.model.resource.ResourceModel",
		"settings": {
			"bundleName": "*******.i18n.i18n"
		}
	},
	"": {
		"dataSource": "mainService",
		"preload": true,
		"settings": {
			"disableHeadRequestForToken": true
		}
	},
	"backend": {
		"dataSource": "****_SRV",
		"preload": true,
		"settings": {
			"loadAnnotationsJoined": true,
			"defaultOperationMode": "Server",
			"defaultBindingMode": "TwoWay"
		}
	}
}

May you help me please?

Cheers,

Sev

Accepted Solutions (1)

Accepted Solutions (1)

sdebeaulieu
Participant

I found a solution. My method getModel was in my BaseController:

		getModel : function (sName) {
			return this.getView().getModel(sName);
		},

For OData models, I created a new function:

		getODataModel : function (sName) {
			return this.getOwnerComponent().getModel(sName);
		},

From now, each OData call is made with getODataModel, and because I call it with getOwnerComponent, model is not destroyed anymore.

Hope it will help.

Cheers,

Sev

Answers (1)

Answers (1)

former_member322772
Active Participant
0 Kudos

Check the network requests in the console. Are any network requests fired the second time? And if so, is there data?