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

History States

How do i get the history (previous states) of a workitem?

0 votes



5 answers

Permanent link
Below is my code in WorkItem Save precondition.

//getServices
IWorkItemServer workItemServer = getService(IWorkItemServer.class);

IWorkItem workItem_newstate = (IWorkItem)saveOperation.getNewState().getFullState();
Identifier<IState> workItemNewState = workItem_newstate.getState2();
IWorkflowInfo workflowInfoNew = workItemServer.findWorkflowInfo(workItem_newstate, monitor);
String stateName_new = workflowInfoNew.getStateName(workItemNewState);


How can I get the previous (history) state of the workitem? I am having hard time to figure this code out.

There are only two forum entries, but it is very hard to figure out the API part
https://jazz.net/forums/viewtopic.php?t=1823&highlight=work+item+history
https://jazz.net/forums/viewtopic.php?t=217&highlight=work+item+history


Thanks.

0 votes


Permanent link
Hi
To get to the previous item states of the work item, you can use

RepositoryItemService#fetchAllStates
an for each of these handles you can do:
RepositoryItemService#fetchState

Then you have a work item where you can read the workflow state as you do in your code snippet.

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
I'm trying to retrieve a previous state of an Auditable. If I have the UUID of the state I'm looking for, is there a way to retrieve this state directly, rather than doing IRepositoryItemService.fetchAllStates and iterating through to find the item with the right state? I was thinking I could maybe create an item handle and set the state on that, then fetch the item, but there doesn't seem to be an API to set the state. Thanks!

Hi
To get to the previous item states of the work item, you can use

RepositoryItemService#fetchAllStates
an for each of these handles you can do:
RepositoryItemService#fetchState

Then you have a work item where you can read the workflow state as you do in your code snippet.

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
Hi
You can use the corresponding IItemType to do this. E.g. for a work item handle:
IWorkItem.ITEM_TYPE.createItemHandle(Object origin, UUID itemId, UUID optionalStateId);

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
Great... it worked! Thanks.
Hi
You can use the corresponding IItemType to do this. E.g. for a work item handle:
IWorkItem.ITEM_TYPE.createItemHandle(Object origin, UUID itemId, UUID optionalStateId);

Regards

Marcel
Jazz Work Item team

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,941

Question asked: Mar 16 '09, 11:05 p.m.

Question was seen: 8,567 times

Last updated: Mar 16 '09, 11:05 p.m.

Confirmation Cancel Confirm