cancel
Showing results for 
Search instead for 
Did you mean: 

oData V4 create entity

Former Member
6,711

Hi,

how do I create a new entity with oData V4 model without having an existing ListBinding?

I have a SimpleForm and want to create a new entity based upon the entered information.

So I tried to manually create a ListBinding as this seems to be the only way to create a new enitty via create() method.

var oListBinding = oModel.bindList("/Templates");
var oContext = oListBinding
    .create({"id":"1"});

But nothing is being sent to the backend.

What am I doing wrong?

All examples I have found base upon a control being bound and used a syntax like this

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

Thanks

View Entire Topic
former_member374496
Participant
0 Kudos

Hello Oliver,

could you explain to me how to create an entity with oData v4? If its possible without List binding, because i dont have a list. I use two input fields to create a new entity.

I have the same requirement as above, could you please let me know if there are any ways to achieve this ? In my case i have FeedInput, User allowed to enter the comment and post it , upon posting the comment shd get saved in the entity and we are using V4 version..

Thanks in advance,

Pradeep

Hello Pradepp,

you must create a list object in your code via:

const oListBindingVehicle = this.getView().getModel("kddietz").bindList("/Vehicle");

On these reference, you can call the function "create".

oListBindingFahrzeug.create(oVehicleDataJson, true);
Mathias_Uhlmann
Product and Topic Expert
Product and Topic Expert