cancel
Showing results for 
Search instead for 
Did you mean: 

Call an update method from a fiori Object page

Former Member
0 Kudos

Hello dear experts,

i'm new in fiori/ sapui5 and i'm working now on a fiori project. i use a worklist template for that. On both pages i have actions(approve and reject.. most act identically on both pages). These Buttons trigger a change in my data and call an update function(crud) to also change the odata in the backend. I use for that ajax, this work pretty fine on the List page. But make trouble in the object/detail page.

Here i perform an update in my backend (Worklist.js) / Worklist page

var batchChanges = [];
                var oUpdateModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/Z_XNEU_SRV/");

jQuery.ajax({
                    // Data request 
                    type: "GET",
                    contentType: "application/json",
                    url: "/sap/opu/odata/sap/Z_XNEU_SRV/",
                    dataType: "json",
                    async: false,
                    success: function() {
         for (i = 0; i < aSelectedItem.length; i++) {
                        // Change Datafield in oUpdateModel
                        //...
             //perform batch operation for backend (PUT)
                            batchChanges.push(oUpdateModel.createBatch                            Operation(
                                sPath,
                                "PUT",
                                oContractObject));
          }
// refresh odata
                        oUpdateModel.addBatchChangeOperations(batchChanges);          
                        oUpdateModel.submitBatch(function(data) {
                            oUpdateModel.refresh();
                        }

and here the update in object.js (object page)

var batchChange = [];
            var oUpModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/Z_XNEU_SRV/");

            jQuery.ajax({
                // Data request 
                type: "GET",
                contentType: "application/json",
                url: "/sap/opu/odata/sap/Z_XNEU_SRV/",
                dataType: "json",
                async: false,
                success: function() {
                    oContractObject = oView.getBindingContext().getObject();
                    // Change Datafield in oUpModel
                    //...

                //perform batch operation for backend (PUT)
                    batchChange.push(oUpModel.createBatchOperation(
                        sPatch,
                        "PUT",
                        oContractObject));
                oUpModel.addBatchChangeOperations(batchChange);
                    oUpModel.submitBatch(function(data) {
                        oUpModel.refresh();

                 });
                }

            });
                

in the object page there is just one object selected, so i don't need a loop when i perform the changes. The "sPatch" and "oContractObject" are filled correctly but the "PUT"-operation don't work for the Object page. Please i need help. Don't understand why..

Accepted Solutions (0)

Answers (0)