Skip to Content
0

UI5 - OData model V2 - Batch Management

Feb 20, 2017 at 02:46 PM

311

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Hans Yustiawan Feb 22, 2017 at 12:00 AM
1

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(){...}

});
Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Hans,

i'll give a try :)

0

Please give me an update if it doesn't work.

I tried my solution and it did work.

0

Hi Hans,

Now the backend is triggered but... not in a single batch!

i expect the follow triggering on backend

  • changeset begin
  • Operation1
  • Operation2
  • Operation3
  • changeset end

But instead i have

  • changeset begin
  • Operation1
  • changeset end
  • changeset begin
  • Operation2
  • changeset end
  • changeset begin
  • Operation3
  • changeset end

Sorry if i'm slow in answering but i'm a bit overhelmed by the workload and this is just the finest solution possible.

i managed some workaround to fix the problem ASAP, promising myself to check a better solution in my spare time.

Thanks for your patience and help!

0

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() {} });
0
Hsia-Liang Tan Feb 21, 2017 at 04:42 PM
0

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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Not error at all.

If i remove the batch management and call the update directly, the backend is triggered.

0