Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Creating follow up condition to create approval records

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

0 votes



2 answers

Permanent link
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

0 votes


Permanent link
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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jun 04 '09, 6:25 a.m.

Question was seen: 5,522 times

Last updated: Jun 04 '09, 6:25 a.m.

Confirmation Cancel Confirm