I'm trying to develop an adaptation project of the F3163 Standard App Fiori Elements (Manage Business Partner Master Data), in order to achieve the following functionalities:
I'm not able to get the data unless the Roles section is already visible on the screen. But I need to get this information at the beginning of the loading of the Object Page, because the visibility of my custom button should be based on this.
I'm not able to fill the fields for a similar reason above. The only scenario I manage to correctly set the values of the fields is when the Address section is on the screen.
Please take a look at the desired output:
Please, could you give some directions about how to achieve these points?
How to correctly fill the fields of an Object Page with Sections?
How to get the information of the business partner at the beginning of the page loading ?
I'm working with Business Application Studio and my target deployment is Fiori S/4HANA 2022 On Premise.
You are trying to use data from one UI element (section) to control the behavior of another UI element (button) – but the data you need is available in the underlying model (which defines the UI behavior in the first place). Therefore, instead of reading this data from the section in the UI, you can read it directly from the data model.
To achieve that, you can use the standard model of the app. This is reachable in the controller code by calling this.getOwnerComponent().getModel(). Then you can use the read method to get the data:
In general, extension code interactions with the standard OData model are not recommended - but for read requests it should be OK.
A drawback would be that data may be read twice, which has a certain performance penalty.
Edit: in the controller extension code the path to get the model is this.getView().getController().getOwnerComponent().getModel()