Skip to Content

oData V4 create entity


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

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


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Apr 05, 2018 at 12:17 PM

    Hi Oliver,

    the request is created only when the respective updateGroup is submitted. Please see the

    Sales Orders sample in the demokit for an example how the creation of a new record could be handled. The request is sent to the backend when the user saves.

      onSaveSalesOrder : function () { 
       * Submits the given batch group while the view is locked.
       * @param {string} sGroupId
       *   the group ID
      submitBatch : function (sGroupId) {
       var oView = this.getView();
       function resetBusy() {
       oView.getModel().submitBatch(sGroupId).then(resetBusy, resetBusy);

    Best regards

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 10, 2018 at 10:50 AM

    Hi Mathias,

    thanks, I now got it to work, adding entities works fine.

    But unfortunatelly I'm unable to process potential errors as the Error Part is never executed.

                var oListBinding = oModel.bindList("/Templates", undefined, undefined, undefined, { $$updateGroupId: "AddTemplate" });
                var oContext = oListBinding
                        "global_tool_id": odd_tools.getSelectedKey(),
                        "template_name": otxt_template_name.getValue()
                    function () {
                        MessageBox.alert(oView.getModel("i18n").getResourceBundle().getText('AddTemplateSuccessMessage') + ' ' + oContext.getProperty("id") + ".", {
                            icon: MessageBox.Icon.SUCCESS,
                            title: oView.getModel("i18n").getResourceBundle().getText('Success')
                    }, function (oError) {
                        MessageBox.alert(oView.getModel("i18n").getResourceBundle().getText(oError.message), {
                            icon: MessageBox.Icon.ERROR,
                            title: oView.getModel("i18n").getResourceBundle().getText('Error')
                oModel.submitBatch("AddTemplate").then(resetBusy, resetBusy);

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 24, 2018 at 07:26 AM

    Hello Oliver,

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

    Add comment
    10|10000 characters needed characters exceeded