cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Odata attribute value in a controller extension of a fiori elements application

michael_vangeet2
Discoverer
0 Kudos
86

Hi experts, 

I'm a bit lost in the methodology of Fiori elements applications using the RAP model with an OData v4 service. 

Backend-wise, I have a full CDS model (with parent/child entities) that are exposed as an OData v4 service. Frontend-wise, I have a Fiori elements application with a controller extension. 

What I am looking to do, is to have the labels of a my child attributes be determined dynamically based on the value of another attribute in the OData entity. Question is: how can I access the value of the attributes in my controller extension? 

I figured out that in the events that can be overwritten (onInit, onBeforeRendering, onAfterRendering), the OData call hasn't occurred yet, so I attached function _onDataReceived to the dataReceived event of the Model (oModel.attachEventOnce("dataReceived", this._onDataReceived.bind(this)); ) in the onBeforeRendering function

This method is being called and I can see that the OData call is performed before it. I am expecting the actual data in aResults (code below), but it is empty. 

        _onDataReceived: function (oEvent) {
            const oModel = this.getView().getModel();
            const oData = oEvent.getParameter("data");
            var aResults = oData.results;
        }  
 
How/Where can I now access the data? 

 

Accepted Solutions (0)

Answers (0)