Skip to Content

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

Jan 08 at 01:32 PM


avatar image
Former Member

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 ...

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Ankit Maskara
Jan 09 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.

10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 09 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.

Show 1 Share
10 |10000 characters needed characters left 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