cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get the model data of the Object Page in my extension in a Fiori Elements app?

0 Kudos
5,082

Hi Fiori Elements experts,

I have an extension to the Object Page which adds a facet. The standard section at the top contains a form with some fields and binding on Text controls displaying data. I want to access this model for my extension.

I have a view.xml and a controller.js in the 'ext' folder for this extension. How can I get the model data of the Object Page in my controller to use in my extension?

I have tried a few different things so far, but none of them work, or are inelegant such as accessing private properties, and even then it doesn't seem to work well. The standard SAPUI5 methods of getting model data do not appear to apply to Fiori Elements apps.

How can I get the correct data for that line item when I navigate to it? I don't want to display data from the previous item.

Thanks,

View Entire Topic
maheshpalavalli
Active Contributor

Hi Matthew Kennedy,

You need to create the extension for the object page(webide) then in the controller you need to write the below code.

sap.ui.controller(listreptest.ext.controller.ObjectPageExt", {
	onInit: function (oEvent) {
		this.extensionAPI.attachPageDataLoaded(function (oEvent) {
			// Here the oEvent.context will have the model, path and stuff
		}.bind(this));
	}
});

Thanks,

Mahesh

johlee66
Discoverer
0 Kudos
perfect solution,thanks Mahesh.