Update Task Data/Bussiness Data when open/close task in MWS

I have several process tasks in parallel with a document reference (let’s say “mydoc”) as business data and I want that when a user open a task, always see the updated information to last.
Therefore, in the task UI, I have a webservice call to reload the document from the database layer and then assign this to the TaskData.mydoc.

But when the user completes the task, the pipeline does not reflect the updated document.

What I am doing wrong?

are you calling task API method, applyChangesNoAccept() (or applyChanges()) after upldating taskdata.mydoc?

I have the following flow implementation in the Complete button:
#{activePageBean.tarea.applyChangesNoAccept}
#{activePageBean.tarea.completeTask}
#{activePageBean.cancelView}

Do you see updated data in the task UI? are there any errors in mws logs?

Yes I see the updated data in UI controls.

And the log does not show any error.
The only strange thing I see: many POST/GET while I’m in the task.

2014-05-29 09:45:18 CEST (Framework:INFO) [RID:5600] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/ (GET)
2014-05-29 09:45:23 CEST (Framework:INFO) [RID:5601] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000004446 (POST)
2014-05-29 09:45:23 CEST (Framework:INFO) [RID:5602] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/B51FFF98-0FA8-7028-3400-C1A20E165830.task.app.details.page (GET)
2014-05-29 09:45:25 CEST (Framework:INFO) [RID:5603] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/ (GET)
2014-05-29 09:45:26 CEST (Framework:INFO) [RID:5604] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:26 CEST (Framework:INFO) [RID:5605] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:26 CEST (Framework:INFO) [RID:5606] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:26 CEST (Framework:INFO) [RID:5607] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:27 CEST (Framework:INFO) [RID:5608] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:27 CEST (Framework:INFO) [RID:5609] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:27 CEST (Framework:INFO) [RID:5610] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:27 CEST (Framework:INFO) [RID:5611] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:27 CEST (Framework:INFO) [RID:5612] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:27 CEST (task:INFO) [RID:5612] - Updating task: /meta/default/task/0000033672
2014-05-29 09:45:27 CEST (task:INFO) [RID:5612] - Updating task: /meta/default/task/0000033672 completed in 62
2014-05-29 09:45:27 CEST (Framework:INFO) [RID:5613] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5614] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5615] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5616] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5617] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5618] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5619] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5620] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5621] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5622] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5623] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5624] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5625] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5626] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5627] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5628] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:28 CEST (Framework:INFO) [RID:5629] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (GET)
2014-05-29 09:45:29 CEST (Framework:INFO) [RID:5630] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:29 CEST (task:INFO) [RID:5630] - Updating task: /meta/default/task/0000033672
2014-05-29 09:45:29 CEST (task:INFO) [RID:5630] - Updating task: /meta/default/task/0000033672 completed in 31
2014-05-29 09:45:29 CEST (task:INFO) [RID:5630] - Updating task: /meta/default/task/0000033672
2014-05-29 09:45:29 CEST (task:INFO) [RID:5630] - Reply Task Completion: 33672
2014-05-29 09:45:30 CEST (task:INFO) [RID:5630] - Updating task: /meta/default/task/0000033672 completed in 172
2014-05-29 09:45:30 CEST (Framework:INFO) [RID:5631] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000032913 (POST)
2014-05-29 09:45:30 CEST (Framework:INFO) [RID:5632] - [6fyweeeeu50t1gr8y8t9jjz6s:Administrator] - http://localhost:8585/meta/default/wm_xt_fabricfolder/0000004446 (GET)
2014-05-29 09:45:30 CEST (task:INFO) [RID:5632] - assignedToListValue is empty,so return all task
2014-05-29 09:45:30 CEST (task:INFO) [RID:5632] - Query Tasks Total Count Paged Task Search Query V2 [from:0; to:2147483647; sortBy: null; sortOrder: asc searchTerms: {taskTypeID in } completed in 0ms

just before completing the task try this get.refresh();

Anjni.
I just want the opposite (not to refresh the TaskData but update it) If I call the refresh method, the original TaskData come back.

If you are calling DB to update task Data and then applyChanges(), the current instance should have the latest data.
calling refresh() before completeTask() will just make sure that the process step is passed with the current pipeline data.
Are you seeing old pipeline data in the next step on intermediate pipeline? can you try logging some pipeline data before completeTask() to know if it still has correct data? Is your environment clustered?

Ok. I solved the problem by modifying the CompleteTask action with the following flow:

#{activePageBean.myWsGetRecord.refresh}
#{activePageBean.mytask.taskData.mydoc} = #{activePageBean.myWsGetRecord.result.record}
#{activePageBean.mytask.applyChanges}
#{activePageBean.mytask.completeTask}
#{activePageBean.cancelView}

Thank you both for the help.

Glad it worked! I think task data was getting refreshed before applychanges call…