Search code examples
odatasapui5

UI5 odata failed to drill down


Hello i set the binding context for an oData request, and the request is called fine. But on ui5, i get the following error:

Failed to drill-down into Id, invalid segment: Id - ../oData/Users('44ce4852-5985-44c3-9a75-03e252747d29')?$select=Email,FirstName,Id,LastName,UserName sap.ui.model.odata.v4.lib._Cache

Controller:

        onInit: function () {

            this.getRouter().getRoute("userDetails").attachPatternMatched(this._onObjectMatched, this);
        },


        _onObjectMatched: function (oEvent) {
            var sUserId = oEvent.getParameter("arguments").userId;

            console.log(sUserId);

            this.getView().bindElement({
                path: "/Users('"+sUserId+"')",
                model: "som"
            });

            console.log(sUserId);
        },

View:

<Page  >

    <fLayout:SimpleForm editable="true"
                        layout="ResponsiveGridLayout"
                        title="{i18n>settings.user.title}"
                        labelSpanXL="3"
                        labelSpanL="3"
                        labelSpanM="3"
                        labelSpanS="12"
                        emptySpanXL="4"
                        emptySpanL="4"
                        emptySpanM="4"
                        emptySpanS="0"
                        columnsXL="1"
                        columnsL="1"
                        columnsM="1" >
        <fLayout:content>

            <Label text="{i18n>settings.user.id}" />
            <Input editable="false" value="{som>Id}" />

            <Label text="{i18n>settings.user.userimage}" />
            <f:Avatar press="onAvatarPressed" imageFitType="Contain" displaySize="XL" />

            <Label text="{i18n>settings.user.username}" />
            <Input value="{som>UserName}" />

            <Label text="{i18n>settings.user.email}" />
            <Input value="{som>Email}" />

            <Label text="{i18n>settings.user.firstname}" />
            <Input value="{som>FirstName}" />

            <Label text="{i18n>settings.user.lastname}" />
            <Input value="{som>LastName}" />

        </fLayout:content>
    </fLayout:SimpleForm>
</Page>

Solution

  • I found the solution, my request was returning a list ant not a single object.