Skip to Content

UI5 - OData model V2 - Batch Management

Hi all

i'm trying to manage the batch processing for my entity with UI5 library (version 1.44.7).

i tried to check the library help and the official help here and this is the code i wrote

oModel.setUseBatch(true);
var groupId = (new Date()).getTime();
var requestParams = {};
requestParams.groupId = groupId;
var calls = items.length;


for(var i=0; i< itemsToSave.length; i++){
	var item = itemsToSave[i];
	oModel.update("/" + entityName + ("(" + item.getId() + ")"), item, requestParams);


}
oModel.setDeferredGroups([groupId]);
oModel.submitChanges({
			groupId:groupId,
			success:function(){...},
			error:function(){...} });

i tried to put a console.log after each step and i see they are performed in my browser console but....no request is sent to the backend server.

Any suggestion?

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 22, 2017 at 12:00 AM

    Hi Simone,

    Have you tried to set your deferredGroups and changeGroups first before you put your data inside update function?

    var sGroupId =(newDate()).getTime();
    var requestParams ={};
    requestParams.groupId = sGroupId;
    
    oModel.setDeferredGroups([sGroupId]);
    
    var calls = items.length;
    
    for(var i=0;i< itemsToSave.length; i++){
    	var item = itemsToSave[i];
    	oModel.update("/" + entityName + ("(" + item.getId() + ")"), item, requestParams);
    }
    oModel.submitChanges({
    			groupId: sGroupId,
    			success:function(){...},
    			error:function(){...}
    
    });
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Simone Milesi

      hmm that's strange. this is my code that do the batch. it does work on mine

      give it try. :) no worries

       oDataModel.setChangeGroups({
           sPath: { groupId: sGroupId } });
      
      
      oDataModel.setDeferredGroups([sGroupId]);
      
      aFormObject.forEach(function(element, index, array) {
            oDataModel.update(sPath + "("+ID+")", element, {groupId: sGroupId});
      });
      
      
      oDataModel.submitChanges({ groupId: sGroupId, success: function() {}, error : function() {} });
  • avatar image
    Former Member
    Feb 21, 2017 at 04:42 PM

    Does the $metadata call returns any error? If the initial $metadata call failed then the subsequent call to the odata service will not be sent out.

    Add comment
    10|10000 characters needed characters exceeded