'concurrency' from service while trying to save second task

I am trying to save two tasks for the same user history. The first request always succeeds, but the second service request always returns this message in response:

Concurrency conflict: [An object has been changed since reading for an update in this context] - ConcurrencyConflictException: Changed since read on update: Object Class: com.f4tech.slm.domain.UserStory: ObjectID:

I use the JavaScript SDK to create a task. I do this twice:

Rally.data.ModelFactory.getModel({ type : 'Task', success : function(task) { var record = Ext.create(task, { Name : taskName, State : 'Defined', TaskIndex : 1, WorkProduct : workProductId, Owner : userIdsTeam[owner], SyncDevelopmentTasktoAccuRev : accuSync, Estimate: hours, TargetDeployment: targetDeployment, context: { project:'/project/' + currentProjectId, projectScopeDown: true }, }); record.save({ callback : afterSaveNewTaskCallback }); } }); 

Is there anything I can do to get rid of this error and successfully save two tasks?

+4
source share
2 answers

Since your tasks are tied to the same main user history, the creators try to block it in order to establish a connection, and why the second does not work. You need to bind callbacks together:

 Rally.data.ModelFactory.getModel({ type : 'Task', success : function(taskModel) { //Create first task var task1 = Ext.create(taskModel, { //...fields... }); task1.save({ callback: function() { //Create second task var task2 = Ext.create(taskModel, { //...fields... }); task2.save({ callback: afterSaveNewTaskCallback }); } }); } }); 
+1
source

In addition to Kyle's answer, you can also use Rally.data.BulkRecordUpdater to create / update the queue for you. http://developer.rallydev.com/apps/2.0p5/doc/#!/api/Rally.data.BulkRecordUpdater

+2
source

All Articles