how can I read history from RTC workItem jazz

2.2k Views Asked by At

how can I read history from RTC workItem. I want to check some attribute change and its value before and after change form history. By jazz API. how its is possible? Please help .

2

There are 2 best solutions below

0
On

Use the below snippet:

IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);

IItemManager itm = teamRepository.itemManager(); 
List history = itm.fetchAllStateHandles((IAuditableHandle) workItem.getStateHandle(), monitor);
System.out.println("Record history details:-");
for(int i = history.size() -1; i >= 0; i--){
    IAuditableHandle audit = (IAuditableHandle) history.get(i);
    IWorkItem workItemPrevious = (IWorkItem) teamRepository.itemManager().fetchCompleteState(audit,null);
    //Operations to be carried on workItemPrevious
}
5
On

Ragarding attributes, you can see more at "Working with Work Item Attributes"

If you have the Attribute ID available as a string, you can use this code to get the attribute.

IWorkItemClient workItemClient = (IWorkItemClient) fTeamRepository.getClientLibrary(IWorkItemClient.class);
IAttribute someAttribute= workItemClient.findAttribute(fProjectArea, "some_attribute_ID", monitor);

For the history, this thread can help

you can use IItemManager.fetchCompleteState() to get the full item in its historical state.
If you want to get the full history you can also get all state handles at once using IItemManager.fetchAllStateHandles() instead of walking the history using IAuditable.getPredecessorState().