cancel
Showing results for 
Search instead for 
Did you mean: 

How to fill fields of a standard app Fiori Elements through Adaptation Project

Pedro
Participant

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:

  • Provide a custom button in the screen which will trigger an odata call to a custom service (Done through extension controller)
  • Provide a confirmation popup for the trigger action of the above button (Done)
  • Enable the button accordingly to the presence of some roles in the table of the section Roles (problem 1)

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.

  • Fill some fields in the address section (standard address subsection) with the response data (problem 2)

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.

gabriel-vilarim
Discoverer
0 Kudos

Interesting use case. Any luck on solve this? I have a similar requeriment on my side

Pedro
Participant
0 Kudos

Hey.

Nothing yet. I'm still struggling in searching into documentation...

Accepted Solutions (1)

Accepted Solutions (1)

VitorSeifert
Advisor
Advisor

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()

Pedro
Participant
0 Kudos

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

Pedro
Participant
0 Kudos

Hi, again.

Regarding to the problem 2, to write on the fields in the screen at the right time, I solved it by triggering the navigation through sections and delaying a bit the filling of data, as follows:

being, oAddressSection the control of the Address Section, for instance.

Best regards!

Pedro

VitorSeifert
Advisor
Advisor
0 Kudos

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

Answers (0)