Change value of workitem in Follow-up action not apply!!!
I am writting a Follow-up action.I want to modified value of two field after the change of any field value of workitem saved. But after changing state of the workitem, the follow action did run, and set setAttribute statement did passed. After follow up action finished. In UI of RTC client, The two fields were not changed at all. The type of two fields both are small string. Why no change? how can I change workitem values in follow up action. Please do not let me try pre condition. Pre-condition is ok, I know. But I want to change value of workitem just after workitem have been saved. I need do some other work after workitem saved not before workitem saved.
The source like below:
public class StreamAutoCreateParticipant extends AbstractScmService implements IOperationParticipant {
IWorkItem newWorkItem = (IWorkItem) saveParameter.getNewState();
IAttribute attr = workItemService.findAttribute(projectArea, "MainProduct", null);
after the source running, the value of SupplementalProduct and MainProduct still not changed.
IWorkItem wk = workItemService.findWorkItemById(newWorkItem.getId(), IWorkItem.FULL_PROFILE, null);
then I try below code,but error occured,
IWorkItem newWorkItem = (IWorkItem) saveParameter.getNewState();
error info :
Please give me an advise.
|
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Nov 15 '13, 4:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Nov 15 '13, 4:22 a.m.
I have to disagree, you are not supposed to change the data of a work item in an advisor/pre condition. See: https://rsjazz.wordpress.com/2012/12/14/do-not-modify-the-triggering-element-in-an-operationadvisor/
https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ , https://rsjazz.wordpress.com/2012/11/27/resolve-parent-if-all-children-are-resolved-participant/ , https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ show examples where the work item gets updated. You get stale data, if the data in the work item is not the most recent. Try to resolve the work item again, before you modify it. silencehill wu selected this answer as the correct answer
Comments
silencehill wu
commented Nov 16 '13, 5:08 a.m.
You mean I can get the workitem the lastest like below:
IWorkItem workingCopy = WorkItemServer
then call workItemServer.saveWorkItem2(workingCopy, null, null); will save the change of value? I mean, stale data says that the item has been modified somewhere else. So before you get the working copy get the work item again, then do the modification and save. You can see in my posts how I do it.
silencehill wu
commented Nov 25 '13, 11:42 a.m.
Thks, it has worked in follow action to refer your post.
But I still have a question, why we can set attribute value directly using setAttribute api without call save api, and it can work immediately in pre-condition, why setAttribute API can not work in follow action directly?
sam detweiler
commented Nov 25 '13, 11:48 a.m.
the attribute should not change in the database unless a workitem Save has been completed.
|
One other answer
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.