It's all about the answers!

Ask a question

How to read Work Item history from RTC using java APIs?


0
1
Mohammed Shalaby (1111) | asked Nov 30 '15, 4:30 a.m.
edited Jul 16 '16, 11:03 a.m. by David Lafreniere (4.8k7)
Dears,
          I am able to read comments and some history items.
But i need i need to read changes in fields values that appears in histroy like the following:

Owned By XYZ  →  ABC
System    EAI  →  Siebel Dev

appreciate your help

Thanks

2 answers



permanent link
Kevin Ramer (4.5k8183200) | answered Dec 16 '15, 2:27 p.m.
This can be done using the repository ItemManager something like the following:


         // workItem is of type IWorkItem
         // repository is of type ITeamRepository
        IAuditableHandle auditableHandle = (IAuditableHandle) workItem.getItemHandle();
         IItemManager itemManager = repository.itemManager();
         
         List<IWorkItemHandle> handles;

        try {
             handles = itemManager.fetchAllStateHandles( auditableHandle, null);
             List<IWorkItem> workItems = new ArrayList<IWorkItem>();
             
             workItems = itemManager.fetchCompleteStates(handles, null);

workItems will contain the history records of the work item ( basically a copy of the prior history state of the work item)
The hard part is the rooting through the list to note the changes you have interest in.     Look at the API doc for the named classes / methods.


Comments
Mathieu Defianas commented Apr 06 '16, 10:25 a.m.

Hello,
Do you think that a method is available to compare the current version of a workitem and an old version ?
In fact, with your example, I can go back to an old state but I haven't got the list of modifications
Thanks for your help
Mathieu


sam detweiler commented Jul 17 '16, 8:52 a.m.

YOU Have to compare the two states to see the differences.


permanent link
Stefano Antoniazzi (1701711) | answered Jul 14 '16, 5:22 a.m.
edited Jul 14 '16, 5:23 a.m.
 I don't know if there's something better but you may get inspiration looking at class ChangePresentation (from com.ibm.team.workitem.service.internal.save.notify.ChangePresentation) where changes of attributes are found using a sorted attribute list (buildSortedAttributeList) and then comparing the values of the attributes in history,

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.