question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OData v4: Change the Reference in a Single-Valued Navigation Property

See original GitHub issue

How am I supposed to change a reference in a single-valued navigation property using the UI5 OData v4 Model? The OData documentation states that this could be accomplished by following request:

PUT serviceRoot/People('russellwhyte')/Trips(1001)/PlanItems(11)/Microsoft.OData.SampleService.Models.TripPin.Flight/Airline/$ref

OData-Version: 4.0
Content-Type: application/json;odata.metadata=minimal
Accept: application/json

{
"@odata.id": "serviceRoot/Airlines('FM')"
}

But I cannot find a way to achieve this by using the UI5 classes in sap.ui.model.odata.v4. Am I missing something? If I try to change the value of the navigation property via the setProperty method of sap.ui.model.odata.v4.Context I get an error that states that $ref is not a (navigation) property. Besides that the setProperty method only allows primitive values.

Any kind of help is much appreciated.

Greetings Marvin

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
uhlmannmcommented, Jul 11, 2022

Hi Marvin,

yes, that is the idea.

Best regards Mathias.

0reactions
Mave213commented, Jul 11, 2022

Alright, thank you very much for your effort! 😃

Kind regards Marvin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the Reference in a Single-Valued Navigation ...
How am I supposed to change a reference in a single-valued navigation property using the UI5 OData v4 Model? The OData documentation states ......
Read more >
OData Version 4.01. Part 1: Protocol - OASIS Open
Relationships from one entity to another are represented as navigation properties. Navigation properties are generally defined as part of an entity type, ...
Read more >
Basic Tutorial · OData - the Best Way to REST
A successful PUT request to a single-valued navigation property's reference resource changes the related entity. The request below change the Airline of a ......
Read more >
Associate and disassociate table rows using the Web API
The easiest and most common way to do this is by appending the @odata.bind annotation to the name of the single-valued navigation property...
Read more >
sap.ui.model.odata.v4.ODataContextBinding - API Reference
ODataModel#submitBatch to submit the changes or sap.ui.model.odata.v4. ... Since 1.98.0, a single-valued navigation property can be treated like a function ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found