Skip to Content
0
Jun 01, 2017 at 05:56 PM

How to get created object when using odata V4

1314 Views Last edit Jun 02, 2017 at 07:47 AM 2 rev

Hi,

I am currently trying to figure out if oData v4 model implementation fits to our needs/ requirements but I am already struggling with adding new entities. After successful creation, I am not able to fetch the returned object, even though I can see that the server includes it in his response.

I tried to follow the Demo App in Explored but I am not able to get it to work.

My code looks like this:

var oContext = this.getView().byId("mainmenulist").getBinding("items")
                .create(oMainMenuItem);

Afterwords I am trying to access this newly created record.

            oContext.created().then(function() {
                oDialog.close();
                MessageBox.alert("Created Main Menu Item with id " + oContext.getProperty("id") + ".", {
                    icon: MessageBox.Icon.SUCCESS,
                    title: "Success"
                });
            }, function(oError) {
                oDialog.close();
                MessageBox.alert("Could not create Main Menu Item: " + oError.message, {
                    icon: MessageBox.Icon.ERROR,
                    title: "Error"
                });
            });

but I always keep getting the error "Failed to drill-down into -1/id, invalid segment: id".

What am I doing wrong?

Thanks for help,

Oliver