Skip to Content
avatar image
Former Member

SAPUI5: How to update a property which is the key for a navigation property.

I'm using an ODATA V2 model in a SAP UI5 application.

The model contains e.g. a set named CAR and a set named COLOR. The CAR set contains a property colorId which is a 1:n navigation property to COLOR:

<NavigationProperty Name="ColorDetails" Relationship="TestApplication.Car_Color_Many_ZeroToOne0" FromRole="Car" ToRole="Color"/>

My UI5 contains a com boBox with all avaiable Colors so that I can ensure that the user cannot select a value for COLOR which is not in the COLOR set.

When I now send an PUT request to the ODATA services all properties are updated except the property colorId.

Can somebody help me or provide me with an example. Thank you ...

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 09, 2018 at 07:38 AM

    On which entity are you triggering PUT . URL please.

    Put request is an update request and in update request we cannot change the key fields. Here I assume Color_Id is key field.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 09, 2018 at 08:35 AM

    carcolormodel2.jpgI'm triggering the PUT request to http://{servername}/TestApplication/data.svc/Cars(1) where 1 is the ID from CAR entity.

    What I want to do is, I just want to update the CAR entity with a new COLOR_ID: The existing car is no longer a red car, it should be updated to a green car.


    Attached also a screenshot from the PUT request trying to update the Car with Id = 1. The carlocation and description is updated. The colorId seems to be ignored and is not updated on the database.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi ...

      Any Error you are getting from the service when you try to PUT the colorId ?? ..Check the console of the browser for the error .. If not than can you test your PUT method of the service from POSTMAN, this way you can determine if the error is from backend or front end ..

      Let me know your findings on this ... this way we can now where to fix this either on frontend or backend