It's all about the answers!

Ask a question

how to get the history of an work item?


0
1
Annie Ying (2063103) | asked Jul 22 '08, 5:32 p.m.
JAZZ DEVELOPER
Hi,

Does anybody know how to get the history of an work item? By history, I mean changes to a given work item. I tried IAuditable.getPredecessorState on an IWorkItem, but when I attempted to get the fields of the predecessor state, I got an IllegalStateException. The error message says "Attempting to get unset feature: InternalState". It's clear that I'm not doing things right, but I have no idea how I should do it correctly. Please help! Thanks!

Annie

Accepted answer


permanent link
Christof Marti (681) | answered Jul 23 '08, 4:35 a.m.
You probably fetched the work item with only part of its properties, 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().

Regards,

Christof
Jazz Work Item team
Ralph Schoon selected this answer as the correct answer

6 other answers



permanent link
Annie Ying (2063103) | answered Jul 25 '08, 7:06 p.m.
JAZZ DEVELOPER
Thanks Christof! What you suggested worked great!

I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)

Thanks!
Annie

Comments
Dashrath Kale commented Jun 18 '15, 3:15 a.m.

Hi Annie

I am trying to do the same thing i.e. fetch the previous states the work itemsusing  IItemManager.fetchAllStateHandles() and I am getting the number of instances equal to the number of the times work item saved. However , I can not fetch the work item states of each instance.

Could you please help on this.


permanent link
Christof Marti (681) | answered Jul 28 '08, 3:43 a.m.
You can use IItem.modified() (which returns a Date instead of a Timestamp).

Regards,

Christof
Jazz Work Item team

permanent link
Manthan Shah (1611) | answered Dec 03 '10, 8:09 a.m.
I am using RTC version 3.0, and accessing JAVA api.

I am facing the following problem while trying to fetch the enumerations:

Code snippet:
IEnumeration<IPriority> enums = (IEnumeration<IPriority>)workItemClient.resolveEnumeration(attribute, null);


Also, the same error occurs, while doing following operation:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", new SysoutProgressMonitor());



Exception in thread "main" java.lang.IllegalArgumentException
at com.ibm.team.process.internal.common.util.AbstractProcess.computeConfigurationData(AbstractProcess.java:328)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:313)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:299)
at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:68)
at com.ibm.team.workitem.common.internal.EnumerationManager$InternalEnumerations.resolve(EnumerationManager.java:52)
at com.ibm.team.workitem.common.internal.EnumerationManager.updateCache(EnumerationManager.java:198)
at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:117)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:74)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65)
at com.ibm.team.workitem.common.internal.EnumerationManager.internalResolve(EnumerationManager.java:173)
at com.ibm.team.workitem.common.internal.EnumerationManager.resolve(EnumerationManager.java:169)
at com.ibm.team.workitem.common.internal.WorkItemCommon.resolveEnumeration(WorkItemCommon.java:453)
at CreateWorkItem.main(CreateWorkItem.java:147)

permanent link
Sunita Dinakar (11413742) | answered Jan 03 '11, 10:03 a.m.
Hello Christof,

I recently went through this post while trying to search any article that explains on reporting out of the history details. This post seems something similar. I would like to start writing reports that can fetch the changes of a work item along with the state changes. Could you please if there is a way I can achieve this, if so how?

Many Thanks,
Regards,
Sunita

Thanks Christof! What you suggested worked great!

I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)

Thanks!
Annie

permanent link
SEC Servizi (97123660) | answered Jun 18 '12, 3:02 a.m.
edited Jun 18 '12, 9:11 a.m.
We would fetch the user id from the predecessor state of a work-item.
We are using the code below:
ITeamRepository repo = ...
IWorkItem wi = ...
IAuditable predecessorState = repo.itemManager().fetchCompleteState(wi.getPredecessorState(), null);
IContributorHandle contributorH = predecessorState.getModifiedBy();
IContributor contributor = (IContributor) repo.itemManager().fetchCompleteItem(contributorH, IItemManager.DEFAULT, null);
String userId = contributor.getUserId());
But the userId is coming from the last contributor who changed the work-item's state, not from the predeccessor... Any advice?
Thanks in advance.

permanent link
chakradhar gowda (111) | answered Mar 08 '17, 7:48 a.m.

 can you share the snippet for the same so that it will helpful for others also.

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.