Skip to Content
0
May 13, 2018 at 04:35 PM

How to insert multiple entries in oModel.create ?

644 Views

Hi Guy's,

I have a dialog box if i select multipull vendor for a product those records should be insert in hana db . for that i wrote below code it is inserting first record only but success msg coming twice.

	handleClose: function(oEvent) {		
	var vendors = oEvent.getParameters("ven").selectedItems ;
	for (var i = 0; i < vendors.length; i++) {
        var item = vendors[i];
        var oModel = this.getView().getModel();
        var oEntry = {};
   oEntry.PRODUCTID  = PRODUCTID;
   oEntry.VENDOR_NO =  item.getDescription() ;
   oEntry.VENDOR_NAME = item.getTitle();
   oEntry.PRICE     = "0";
   oEntry.STATUS    = "X" ;
   oModel.create("/ADDVENDOR", oEntry, {
	success: function(oEvt){
		
	},
	error: function(oError) {
									if (oError.responseText.split("<MSG_TYPE>")[1].split("")[0] === "S") {
										MessageBox.success("Vendor Add Successfully ");
									} else {
										MessageBox.error("Vendor already exist for Product");
      					
								}
	}
   });   

    }
				},

Attachments

capture.jpg (16.3 kB)