Skip to content

Commit

Permalink
Fill ID with random number #13
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf committed Sep 6, 2017
1 parent 03c72a2 commit 35265aa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions webapp/controller/CreateEntity.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ sap.ui.define([
/* =========================================================== */
/* Internal functions
/* =========================================================== */

getRandomInt: function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
},

/**
* Navigates back in the browser history, if the entry was created by this app.
* If not, it navigates to the Details page
Expand Down Expand Up @@ -187,7 +194,11 @@ sap.ui.define([

this._oViewModel.setProperty("/viewTitle", this._oResourceBundle.getText("createViewTitle"));
this._oViewModel.setProperty("/mode", "create");
var oProperties = {
ID: this.getRandomInt(1, 10000000)
};
var oContext = this._oODataModel.createEntry("Events", {
properties: oProperties,
success: this._fnEntityCreated.bind(this),
error: this._fnEntityCreationFailed.bind(this)
});
Expand Down

0 comments on commit 35265aa

Please sign in to comment.