cancel
Showing results for 
Search instead for 
Did you mean: 

Intercept Go (Start)-Button in Fiori Elements List Report Template (OData V4)

termanico
Participant

Hi Community,

I'm working as Fiori/UI5 Developer for Stadtwerke München (SWM) - the local Utilities Company in Munich.

I've got an urgent Requirement from our End-Users:

In one of our Fiori Elements List Reports (OData V4), there are 2 filter fields on the filter bar.

At least one of these 2 fields must be filled with a value (provided by the End-User). It's ok if both are filled, but it's not ok, if none is filled.

In this case we need to generate an error message and prevent the framework from calling the OData Service for reading the data.

We cannot simply set both fields to mandatory, because it must be possible to fill just one field.

And simply attaching an event handler to the Go-Button doesn't do the trick, either, because the service-call (read) is triggered beforehand.

So, it would be great to have a hook (e.g. via controller extension) in order to intercept the read trigger after pushing the Go (Start)-Button or the Enter Button with focus on a filter field.

I saw, that there are a couple of framework hooks in Edit mode - but none in read mode 😞

Does anyone had a similar problem and found a solution for it?

Any kind of help is more than welcomed 🙂

I think Durga Prasanth had a similar question:

validation-on-go-button-in-fiori-element-list-report

Unfortunately, the answer didn't solve our problem.

Regards

Thorsten Klingbeil

gregorw
Active Contributor
0 Kudos

Hi Thorsten,

would it be an option to solve this in the backend?

CU
Gregor

termanico
Participant
0 Kudos

Thanks for the quick response, Gregor!

I thought of this as well and asked our backend developers for help 🙂

They tried to solve it in the underlying Rap-Model (behavior definition), but couldn‘t find a solution for it, either.

Additionally, we want to suppress any backend Communication because of performance reasons - there would be a long backend runtime and a huge resulting data volume in the OData response in case of no filter values supplied in the 2 filter fields 😞

Would be good to know, if other customers have the same requirement and if the Fiori Elements development team within SAP has any plans to add this Extension Option to the framework 🙂

Br

Thorsten

preethi_ande
Participant
0 Kudos

Hi termanico,

Did you get any solution, we have similar kind of requirement.

Please let me know, if you are done with it.

Thanks,

Preethi Ande

termanico
Participant

Hi Preethi,

we finally solved it in the backend (Validation and Error Message in the OData-Service).

However, I found this article in the UI5 docs: Extension Points for Views in the List Report

There are two hooks mentioned which can be overridden in a Controller Extension (onViewNeedsRefresh / on PendingFilters):

sap.ui.define(["sap/ui/core/mvc/ControllerExtension", "sap/ui/model/Filter"], function(ControllerExtension, Filter) {
    "use strict";
    return ControllerExtension.extend("BusinessPartners.custom.LRExtend", {
        override: {
            onViewNeedsRefresh: function(mParameters) {
                var oFilterInfo = mParameters.filterConditions;
                if (oFilterInfo) {
                    var duplicateFilterInfo = Object.assign({}, oFilterInfo);
                    if (
                        duplicateFilterInfo.Region &&
                        duplicateFilterInfo.Region.map(item => item.values).findIndex(i => i.includes("Bavaria")) !== -1
                    ) {
                        delete duplicateFilterInfo.Region;
                    }
                    var oTable = this.getView().byId("BusinessPartners::BusinessPartnersList--fe::CustomTab::tab2--customViewWithTable"),
                        oBinding = oTable.getBinding("items"),
                        oConvertedFilter = this.base.getExtensionAPI().createFiltersFromFilterConditions(duplicateFilterInfo);
                    oTable.setShowOverlay(false);
                    var oFilter = new Filter({ filters: oConvertedFilter.filters, and: true });
                    oBinding.filter(oFilter);
                    oBinding.changeParameters({$search: oConvertedFilter.search});
                }
            },
            onPendingFilters: function() {
                var oTable = this.getView().byId("BusinessPartners::BusinessPartnersList--fe::CustomTab::tab2--customViewWithTable");
                if (oTable) {
                    oTable.setShowOverlay(true);
                }
            }
        }
    });
});

Maybe this helps ...

br

Thorsten

preethi_ande
Participant
0 Kudos

Hi Thorsten,

Thanks for the reply, I have used onPendingFilters hook method and handled the validation.

It is working as expected.

Best Regards,

Preethi

xiaoru
Discoverer
0 Kudos

Hi preethi,

I have a similar issue here, and i saw that you've already solved it.

could you please tell me how this specific code is implemented?

this is my first SAPUI5 and i'm not even sure how to obtain the input values of the selection field

thanks in advance and best regards

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_neuhauser
Explorer
0 Kudos

Hello Thorsten,

my name is Thomas Neuhauser and I'm part of the development team working on Fiori Elements v4.

I checked your requirement with our architects and experts and your analysis and conclusion is correct. Currently there is no hook in the framework supporting what you want to achieve and doing this check in the backend service is the right approach.

However I forwarded your requirement to our product owners so that they may consider this as a requirement for future releases.

Best Regards,

Thomas Neuhauser

termanico
Participant
0 Kudos

Many thanks thomas.neuhauser - I appreciate your support!

Since it's kind of business logic, doing the validation in the backend is fine for us (our golden rule: business logic belongs in the backend!)

However, in terms of better UX (performance) - a pure frontend option would be very helpful! 🙂

In our Company, SAPUI5 is regularly benchmarked against modern Open Source Frameworks like react, qwik, solid, svelte, etc. 😉

br

Thorsten

rammel_sapdev
Participant
0 Kudos
Hi @thomas_neuhauser, how do we handle this from the backend service? Is there a way we can display error messages upon clicking the GO button for fiori apps created using managed query (CDS views) or unmanaged query (custom entities)?