It's all about the answers!

Ask a question

How to get the last work-item action


SEC Servizi (97123660) | asked Mar 04 '16, 10:20 a.m.
We need to retrieve the last action performed for a work-item.
In the work-item history we only see the name of the source and target state, but not the name of the action performed. Even the history API service seems to offer only the HTML content for the history:
ChangeLogDTO[] history = wiRepoService.computeHistory(wi);
String htmlContent = history[0].getHtmlContent(); // ???
Any advice?
Thanks in advance.

7 answers



permanent link
SEC Servizi (97123660) | answered Mar 08 '16, 4:52 a.m.
Thank you for reporting that, Nate.
Which REST API should we use? We cannot find the attribute node "stateTransitions" on the Wiki page https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI#workItem_type_com_ibm_team_worki
Thanks in advance.

permanent link
Nate Decker (37814261) | answered Mar 07 '16, 2:26 p.m.

I was working on something else today and noticed that the REST API includes definitions for state transitions. In the REST API, there is an attribute node called:

stateTransitionsitions

It has the following properties:

helperId

transitionDate

action

sourceStateId

sourceResolutionId

sourceWorkflowId

targetStateId

targetResolutionId

targetWorkflowId

changedBy

sourceProjectArea

targetProjectArea

It looks like this might be able to get you what you are looking for. I'm not sure why I never noticed it before. I'm not sure if you are working with the REST API or if this would be a viable solution, but there it is for what it's worth.


permanent link
SEC Servizi (97123660) | answered Mar 07 '16, 3:22 a.m.
the action itself is not saved, also the changes to the process config are not saved in the history
Well, this appears to us a weak solution for a change and configuration management tool... We will open an enhanchement request for that.
Thank you guys for your answers.

Comments
SEC Servizi commented Mar 07 '16, 4:46 a.m. | edited Mar 07 '16, 4:47 a.m.

Enhancement 386170


permanent link
Donald Nong (14.5k414) | answered Mar 06 '16, 10:06 p.m.
One of my clients had similar requests (for audit purpose) in the past, and what they ended up is adding a String attribute to hold the sequence of action names and timestamps and assigning its value programmatically.

permanent link
sam detweiler (12.5k6195201) | answered Mar 05 '16, 8:37 a.m.
As Nate says, you will have to work it out yourself.. the action itself is not saved.
also the changes to the process config are not saved in the history,

permanent link
Nate Decker (37814261) | answered Mar 08 '16, 8:24 a.m.
edited Mar 08 '16, 8:26 a.m.

The REST API is really sort of self-documenting and it's unfortunate that wiki page doesn't do a better job of emphasizing that. Try the following URL:

https://server:port/ccm/rpt/repository/workitem?fields=workitem/workItem[id=#](*)

The asterisk '*' causes the server to response with ALL XML nodes at the top level. If you want nested nodes one level down, you can request (*/*). If you want nodes 3 levels down: (*/*/*) etc... Using this process, you can see all the data the server supplies, even if it's data that isn't documented on the wiki  That will reveal that stateTransitions is one of the XML nodes. Once you identify that this node is available, you can investigate that node further:

https://server:port/ccm/rpt/repository/workitem?fields=workitem/workItem[id=#](stateTransitions/*)


permanent link
Nate Decker (37814261) | answered Mar 04 '16, 12:59 p.m.

If you the Java API as an available tool, you can fetch the workflow definitions and see which actions are available for a given state as well as the target state for those actions. If you know the currents state and the previous state, there should be only one action that could have gotten you to that state.

If the Java API is NOT available, then you could hard-code a look-up table in your code. Admittedly, that's not an ideal solution since it would require maintenance whenever a workflow was changed.

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.