How to get the last work-item action
ChangeLogDTO[] history = wiRepoService.computeHistory(wi);
String htmlContent = history[0].getHtmlContent(); // ???
7 answers
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.
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/*)
the action itself is not saved, also the changes to the process config are not saved in the historyWell, this appears to us a weak solution for a change and configuration management tool... We will open an enhanchement request for that.
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.