Skip to Content
avatar image
Former Member

How to bind createentry without calling the backend.

I have an SAPUI5 application that allows the user to create a new record. The view I'm using is bound to an oData model. I use the Model.createEntry method to create the new entry but when I bind the context to the view, the model performs a GET request to the service for the record with the temporary key of the new entry context.

Obviously, this returns an error from service. How do I do this without triggering the GET request?

		/** 
		 * creates a new entity and saves off the existing context so the focus will return
		 * to it if the user cancels the save.  This will also clear the selected item
		 * from the list.
		 */
		addNewDetail: function(sEntityPath, oEntityProperties) {
			this.getModel().metadataLoaded().then(function() {
				this.getViewModel(this.getMasterPage()).setProperty("/lastContext", this.getView().getBindingContext());
				this.getViewModel(this.getMasterPage()).setProperty("/lastItem", this.getMasterList().getSelectedItem());
				var newContext = this.getModel().createEntry(sEntityPath, {
					properties: oEntityProperties
				});
		this.getModel().metadataLoaded().then(function() {
		//			this.getView().unbindElement();
					this.getView().setBindingContext(newContext);
					this.getMasterPage().getController()._oListSelector.clearMasterListSelection();
					this.getViewModel().setProperty("/hasChanged", true);
				}.bind(this));
			}.bind(this));
		},


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Mar 29 at 02:33 PM

    I found out what it was. The form I was binding to had controls bound to Navigation properties of the entity. This appears to force the model to call the Get service method with $expand for the Navigation properties. Once I unbound these controls the calls to the service did not happen.

    Add comment
    10|10000 characters needed characters exceeded