Skip to Content
0

Invalid key predicate type. Expected type is 'Edm.String'

Jun 21, 2017 at 07:52 AM

683

avatar image
Former Member

Hi

I've created a split app and called OData to display a list in the master page.

Now I'm trying to navigate from the master page list items to their details.

This is the code:

MasterView.contoller.js

onListItemPress : function(evt) {
    var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
    var selectedSwapN = evt.getSource().getBindingContext()
                .getProperty("Swapn");
    oRouter.navTo("DetailView", {
        Swapn : selectedSwapN 
    });
    sap.m.MessageToast.show(evt.getSource().getBindingContext()
                .getProperty("Swapn") );
}

DetailView.controller.js

onInit: function () {
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            oRouter.getRoute("DetailView").attachMatched(this._onRouteMatched, this);
            
            
        },
        _onRouteMatched : function (oEvent) {
            var oArgs, oView;
            oArgs = oEvent.getParameter("arguments");
            oView = this.getView();
            oView.bindElement({
                path : "/ET_SWAPSet(" + oArgs.Swapn + ")",
                events : {
                    dataRequested: function () {
                        oView.setBusy(true);
                    },
                    dataReceived: function () {
                        oView.setBusy(false);
                    }
                }
            });
        }

Manifest.json

"routing": {
            "config": {
                "viewType": "XML",
                "viewPath": "ZMOB_BDJS_PENDING_APPROVAL.view",
                "targetAggregation": "detailPages",
                "clearTarget": false
            },
            "routes": [{
                "pattern": "",
                "name": "",
                "view": "MasterView",
                "targetAggregation": "masterPages",
                "targetControl": "splitapp",
                "subroutes": [{
                    "pattern": "DetailView/{Swapn}",
                    "name": "DetailView",
                    "view": "DetailView",
                    "targetAggregation": "detailPages"
                }]
            }]
        }

I'm able to get the selected item but I'm having issue with displaying the details.

The error I'm getting is with pattern I've added in the subrouts.

"pattern": "DetailView/{Swapn}"

This is the error:

The following problem occurred: HTTP request failed400,Bad Request,{"error":{"code":"005056A509B11EE1B9A8FEC11C22778E","message":{"lang":"en","value":"Invalid key predicate type for 'Swapn'. Expected type is 'Edm.String'"},"innererror":{"transactionid":"325456E77FEFF15E811700505680552C","timestamp":"20170621073530.0200000","Error_Resolution":{"SAP_Transaction":"Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"}}}}

I've checked the key type which is Swapn in the OData and it is Edm.String

How can I fix the issue?

Thanks

key.png (1.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Jun 22, 2017 at 07:56 AM
1

I resolved the issue by adding a single qoute in the path in DetailView.controller.js

onInit: function () {
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            oRouter.getRoute("DetailView").attachMatched(this._onRouteMatched, this);
    
        },
        _onRouteMatched : function (oEvent) {
            var oArgs, oView;
            oArgs = oEvent.getParameter("arguments");
            oView = this.getView();
            oView.bindElement({
                path : "/ET_SWAPSet('" + oArgs.Swapn + "')",
                events : {
                    dataRequested: function () {
                        oView.setBusy(true);
                    },
                    dataReceived: function () {
                        oView.setBusy(false);
                    }
                }
            
            });
        }
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi N., your blog just helped me so much. Thanks for adding the solution afterwards. That's really cool :)
CU, Klaus

0