Skip to Content
0
Sep 27, 2016 at 02:02 PM

Create new ticket from Fragments

33 Views

Hi Experts,

My requirement is to create new ticket fetching details from fragments. I have odata table with single select option. On clicking a row and clicking the "Create Ticket" button a fragment will be displayed with the data of the row as below

On clicking the "Submit" button in the fragment I should be create new ticket with the data. I tried the below code to implement the create functionality.

submitticket: function(oEvent) {
var a = this.getView().byId("idibaseTable");
  var oBindingContext = a.getSelectedItem().getBindingContext();
  var service = this.getView().byId("idibaseTable").getModel().getProperty(oBindingContext.getPath());
  var oEntry = this.getView().byId("idibaseTable").getModel().getProperty(oBindingContext.getPath());
  oEntry.type = service.ProcessingTypeCodeText;
  oEntry.SerialID = service.SerialID;
  oEntry.ServicePriorityCodeText = service.ServicePriorityCodeText;
  oEntry.ProductID = service.ProductID;
  oEntry.CustomerID = service.CustomerID;
  oEntry.WarrantyFrom = service.WarrantyFrom;
  oEntry.WarrantyTo = service.WarrantyTo;
  // var oModel = new sap.ui.model.odata.ODataModel("/sap/c4c/odata/v1/c4codata/");
  var oModel = this.getView().getModel("ticketCreate");
  // this.getView().setModel(oModel);
  console.log("model", oModel);
  oModel.create("/ServiceRequestCollection", oEntry, null, function() {
  var msg = "New Service Ticket has been created successfully.";
  MessageBox.show(msg);
  });
  },

I am facing an error here saying "oModel.create is not a function". Please provide suggestions on how this can be implemented.

Thanks,

Srinivasan

Attachments

createticket.PNG (43.1 kB)