I'm new to SAP UI5 (Html/JS). I'm currently developing a form for free text item ordering within SRM UI AddOn environment. When the user is done filling the form he clicks the Submit button, the form should disappear and the item should be transferred back to SRM shopping cart. Now I've difficulty implementing the item transfer. I've tried solution in this article (SAPUI5 oModel.create() - how to post data to the SAP backend?) but nothing happens after the code has been executed.
var oParameters = {
"NEW_ITEM-DESCRIPTION[1]": description,
"NEW_ITEM-QUANTITY[1]": itemQuantity,
"NEW_ITEM-UNIT[1]": itemUnit,
"NEW_ITEM-PRICE[1]": itemPrice,
"NEW_ITEM-CURRENCY[1]": itemCurrency
};
// use oDataModel.create() to POST free text item to SRM shopping cart
var oDataModel = this.getView().getModel();
// Enable messagebox from jQuery
jQuery.sap.require("sap.ui.commons.MessageBox");
oDataModel.create(hook_url, oParameters, null,
function() {
sap.ui.commons.MessageBox.show(sap.ui.commons.MessageBox.alert("Success!"));
},
function() {
sap.ui.commons.MessageBox.alert("Error!");
}
);
I can manually make an http request (string) combining form location (hook_url) and item information. If I open an empty browser page, paste this string in address bar and hit enter the item would be transferred to shopping cart. I'm wondering if I should use an xml http request in the code to simulate it. Does anyone have a clue how to do it?
Thanks in advance!