user10378010
user10378010

Reputation: 41

How to pass input value to entityset of odata from ui5 screen

I am trying to pass a value from fiori screen to oData and want to read the entityset method.But when I check the debugger in odata the it_key_tab has zero records.

    onNext: function(oEvent) {
            var oViewModel = {};
            oViewModel.MBLNR = this.getView().byId("idMd").getValue();
            oViewModel.MJAHR = this.getView().byId("idFy").getValue();
            if (oViewModel.MBLNR === "") {
                var msg = ("Please Enter the material Doc No.");
                MessageToast.show(msg);
            } else
            if (oViewModel.MJAHR === "") {
                msg = ("Please Enter the fiscal year");
                MessageToast.show(msg);
            } else {
                var oModel = this.getView().getModel();
                var oFilter = new Filter("MBLNR", FilterOperator.EQ, oViewModel.MBLNR);
                //var oFilter1 = new Filter("MJAHR", FilterOperator.EQ, oViewModel.MJAHR);
                var aFilters = new Filter({
                    filters: [oFilter]
                });

                oModel.read("/MaterialDocReservationSet", null, {
                    filters: [aFilters],
                    //this.getView().getModel().read("/UserInputSet", oViewModel, {
                    success: function(OData, response) {},
                    error: function(OData, response) {
                        //MessageToast.show("Error");
                    }

                });
            }

Upvotes: 0

Views: 5629

Answers (2)

gcarinodev
gcarinodev

Reputation: 21

In your oData read, remove null parameter. Also filters should be: filters: [oFilter]. Filters property can accept an array containing filter objects, in your code you have nested arrays and filters.

Upvotes: 1

rikusv
rikusv

Reputation: 656

In your front-end code, your are calling oModel.read("/MaterialDocReservationSet", null, {...}). According to the documentation, you should be calling read(sPath, {...}) (without your second parameter null).

In backend Gateway OData GET_ENTITYSET method, you should be accessing the filters using the filter methods of io_tech_request_context. it_key_tab has to do with the key in a GET_ENTITY (corresponding OData URI e.g. MaterialDocReservationSet(1)).

Upvotes: 0

Related Questions