Skip to Content
Jun 07 at 03:01 PM

SAPUI5 new record with Odata V4 no UI list.


Need to upgrade the following SAPUI5 Odata V2 code to Odata V4. The oNewRecord data is not bound to any UI list or control but is created by a posting process. It is a new record and not an update so a POST is needed.

I have found examples using list control to get binding and then creating the context. In this case there is no control. How do I get or create a binding so the new record can be inserted?

In manifest.json:

"serviceCalls": {
"dataSource": "serviceCalls",
"type": "sap.ui.model.odata.v4.ODataModel",
"preload": false,
"settings": {
"synchronizationMode": "None",
"groupId": "$auto",
"operationMode": "Server",
"autoExpandSelect": true


var dataModel = this.getView().getModel("serviceCall");
var oNewRecord = dataModel.getProperty("/value/0");
var oServiceCallModel = this.getOwnerComponent().getModel("serviceCalls");
var mParams = {};
mParams.success = function () {"Create Successful!");
mParams.error = this.onErrorCall;
oServiceCallModel.create("/ServiceCalls",oNewRecord,mParams); (Odata V2 Method).

Expected result:

Http batch request containing POST creates new data record.

Actual result:

error - method not defined.

What is the best way to create a new record in the DB using oData V4 when model is not bound to any control? Please provide short code example if possible.

Thanks for any help.