SAPUI5 & OData v4: Update of derived entity leads to Error: Not a (navigation) property

Viewed 173

OpenUI5 version: 1.95

Browser/version: Chrome Version 101.0.4951.67

I have an OData v4 service with following Entity types (snippet from metadata document):

"name.space": {
    "$Alias": "NmSpc",
    "Flange": {
        "$Kind": "EntityType",
        "$Key": [
            "guid"
        ],
        "guid": {
            "$Type": "Edm.String"
        },
        "controlUnit": {
            "$Kind": "NavigationProperty",
            "$Type": "NmSpc.ControlUnit",
            "$ContainsTarget": true
        },
    }
    "ControlUnit": {
        "$Kind": "EntityType",
        "$Abstract": true,
        "$Key": [
            "guid"
        ],
        "guid": {
            "$Type": "Edm.String"
        }
    },
    "ControlWheel": {
        "$Kind": "EntityType",
        "$BaseType": "NmSpc.ControlUnit",
        "number": {
            "$Type": "Edm.Int32"
        },
    }
}

Now, I am trying to bind the attribute "number" of the ControlWheel, which is an derived Type of ControlUnit, to my view:

let sFlangeGuid = '7c9bf396-d12c-11ec-cb91-0000021cb358';

let oTable = new sap.m.Table({
    columns : [
        new sap.m.Column({
            header : new sap.m.Text({
                text : "Number"
            })
        })
    ], 
    items : [
        new sap.m.ColumnListItem({
            cells : [
                new sap.m.Input({
                    value : {path : "model>number", targetType : "any"}
                })
            ]
        })
    ]
});

oTable.bindObject({
    path : `model>/Flanges('${sFlangeGuid}')/controlUnit`
    //path : `model>/Flanges('${sFlangeGuid}')/controlUnit/name.space.ContolWheel`
});

What is the expected result? I expect a two-way binding between view and model that is functioning both ways.

What happens instead? The value of number is displayed in the input field, so at least the one-way binding seems to work but as soon as i change the value of the sap.m.Input and trigger the change event, following error occurs:

Failed to update path /Flanges('7c9bf396-d12c-11ec-cb91-0000021cb358')/controlUnit/number - Error: /Flanges('7c9bf396-d12c-11ec-cb91-0000021cb358')/controlUnit/number: Not a (navigation) property: number

If i switch to the other path of the bindObject method (which i commented out) i get the following error:

Failed to update path /Flanges('7c9bf396-d12c-11ec-cb91-0000021cb358')/controlUnit/name.space.ControlWheel/number- Error: /Flanges('7c9bf396-d12c-11ec-cb91-0000021cb358')/controlUnit/name.space.ControlWheel/number: Not a (navigation) property: name.space.ControlWheel

The Path above returns the number if i send the request via postman but ui5 somehow decides not to send a request but throw an error beforehand. It seems the ui5 framework can't resolve the derived entity type correctly.

0 Answers
Related