It's all about the answers!

Ask a question

Creating follow up condition to create approval records


megha mittal (15112615) | asked Jun 04 '09, 6:25 a.m.
Hi,
I am trying to write a follow up condition to generate approval records on transition to a particular state.
I got the new state and was able to compare it and now when i am trying to create approval records and trying to save WI using

IWorkItemServer workItemServer= getService(IWorkItemServer.class);
IStatus status =workItemServer.saveWorkItem2(workItem, null, null);

I am getting staleDataException. Pls help me on this.

Thanks

2 answers



permanent link
Simon Fisher (1631710) | answered Jul 17 '09, 12:16 p.m.
JAZZ DEVELOPER
I had this problem too - originally I was using ISaveParameter.getNewState() method to retrieve the work item object. It turns out this gets the state of the object before it is persisted into the repository. Try something like this instead:

IWorkItem newState = (IWorkItem)saveParameter.getNewState();
IWorkItem workItem = (IWorkItem)wiService.findWorkItemById(
newState.getId(), IWorkItem.FULL_PROFILE, monitor).getWorkingCopy();
IStatus status =workItemServer.saveWorkItem2(workItem, null, null);

This gets you a fresh copy of the work item from the repository to work with.

Hope this helps.

Simon

permanent link
megha mittal (15112615) | answered Jul 24 '09, 8:01 a.m.
Thanks a lot.This is exactly what i was looking for.
I had this problem too - originally I was using ISaveParameter.getNewState() method to retrieve the work item object. It turns out this gets the state of the object before it is persisted into the repository. Try something like this instead:

IWorkItem newState = (IWorkItem)saveParameter.getNewState();
IWorkItem workItem = (IWorkItem)wiService.findWorkItemById(
newState.getId(), IWorkItem.FULL_PROFILE, monitor).getWorkingCopy();
IStatus status =workItemServer.saveWorkItem2(workItem, null, null);

This gets you a fresh copy of the work item from the repository to work with.

Hope this helps.

Simon

Your answer


Register or to post 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.