cancel
Showing results for 
Search instead for 
Did you mean: 

Extending Fiori Elements, make a field read-only

RaminS
Active Participant
349

We have a simple requirement for Create Preliminary Billing Documents F2876 to default the Billing Date to today, and make it read-only so the user cannot change it.

This field is not a database field there is no CDS view to extend. It's a local input field bound to a local JSON model that will be sent to the backend Create method. 

 

RaminS_0-1723559143974.png

I created an Adaptation project and added a controller extension. I was hoping to set the value of this field in the JSON model to today's date in the onInit( ) method, and make the field read-only .

 

 

onInit: function() {				
   var oView = this.getView();
   ExtensionAPI.getExtensionAPIPromise( oView ).then(function (oExtensionAPI) {

     var settings = oView.getModel("settings").getData();
     oView.getModel("settings").setProperty("/requestedBillingDocumentDate", new Date());

   }.bind(this))

},

 

However, when my onInit method gets triggered the view has no model, nothing has been loaded and I can't get a hold of anything. 

I tried to hook into the ExtensionAPI, but the extentionAPI doesn't seem to exist at that point.

Can someone please give me some hints on what the proper way is to use Extension APi to get a handle on the view model and events?

The example extension codes provided are all about simple scenario of adding a new button, none of them talk about manipulating view models or events.

Thanks 

RaminS
Active Participant
0 Kudos

After some investigation, I realized that I need to call a private method in the original controller:

RaminS_0-1723652347160.png

Without this method the local JSON model is not initialized and hence I cannot override the model property I want to change. 

How do you invoke a private method of the original controller?

 

 

 

 

RaminS
Active Participant
0 Kudos

Looking at the original app source, I realized that the field I want to override is part of an SAP-written extension to the List Report FE, so I cannot override the methods in this extension.

RaminS_0-1723750589733.png

In that extension controller they have a method that I need to override:

RaminS_0-1723750819731.png

Does anyone know how to extend and override an extension controller of an FE app?

There must be a way using extensionAPI object.

Thanks.

Bingyang1
Associate
Associate
0 Kudos
When onInit, the _oParameterPickerDialog is not defined. before definition, the date pick cannot be got.

Accepted Solutions (0)

Answers (1)

Answers (1)

RaminS
Active Participant
0 Kudos

It appears that this is not possible. By making this input field bound to a local JSON model, the SAP developers have made it impossible to override the field value or set its properties (read-only). 

This is a little hard for our client to accept; with all the promise of extensibility: Adaptation Projects, controller extensions, component configuration, key-user UI Adaptations, Personalizations, none of these layers provide a simple option to set a value of an input field. And it's such an important field, Billing Document Date has so many down-stream consequences in FI/CO.

Our client simply won't accept that there is no work around for this issue.

 

hristotsolev
Product and Topic Expert
Product and Topic Expert

Hi,

have you tried this approach - adding a change file with similar contents:

{
    "changeType": "propertyChange",
    "reference": "app.variant1",
    "namespace": "apps/app.variant1/changes/",
    "projectId": "app.variant1",
    "packageName": "$TMP",
    "support": {
        "generator": "sap.ui.rta.command",
        "command": "property",
        "sapui5Version": "1.129.0-SNAPSHOT"
    },
    "originalLanguage": "EN",
    "layer": "VENDOR",
    "fileType": "change",
    "fileName": "id_1724312853700_249_propertyChange",
    "content": {
        "property": "editable",
        "newValue": false
    },
    "texts": {},
    "selector": {
        "id": "cus.sd.prebillingdoc.creates1::sap.suite.ui.generic.template.ListReport.view.ListReport::C_PrelimBillingDueListItem--InvoiceDatePicker",
        "type": "sap.m.DatePicker",
        "idIsLocal": false
    },
    "dependentSelector": {},
    "jsOnly": false,
    "creation": "2024-08-22T07:48:37.006Z"
}
 
Regards,
Hristo
RaminS
Active Participant
0 Kudos

Hi @hristotsolev ,

That is a really good suggestion, I'll give it a try.

But how would you set the value of the date field to today's date in the change file? 

Thanks