on 11-09-2023 11:42 PM
Hi Experts!
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.
Dear Pedro,
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:
https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel%23methods/read
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.
Best regards,
Vitor Seifert
Edit: in the controller extension code the path to get the model is this.getView().getController().getOwnerComponent().getModel()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Vitor!
Sorry by the delay!
I'm not able to access the getOwnerComponent() method of this in the extension controller of the adaptation project. As you can see in the screenshot below:
But, following the core of your idea, I was able to read the standard odata service by doing this.base.getView().getModel().read().
In order to get the path I needed, I proceeded as follows:
In other words, I just got the odata service by taking a look on the bindingContext of a field on the screen. This solves the problem 1 (take a decision based on the value of some properties).
At the next comment I'll put my solution to the problem 2.
Thank you a lot!
Best regards.
Pedro Lázaro
Hi Pedro,
To get the owner component on the controller extension you actually have to use this path:
this.getView().getController().getOwnerComponent()
Regarding your second problem, it is generally not recommended to use timeouts since they can stop working if the application flow changes or if, for example, the data is taking a long time to load. Instead you should find a suitable event and register an event handler - meaning that your code will only execute after the event is raised. This way you ensure that your code will be executed at the right time. For example, for the event https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.odata.v2.ODataModel%23events/requestComplete... you can register an event handler by calling "onRequestCompleted" on the model.
Best regards,
Vitor
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.