How to get the work item changed attribute and its new/old value for save work item operation follow up action?
I want to develop the follow-up action for the save work item operation to deal with the changed attribute and changed value.
Any one can help to tell me how to get the changed attribute and value for the operation? I see the workshop can deal with the operation data to get old status and new status, but how to get the changed attribute and the changed attribute's old value and new value? Object data = operation.getOperationData(); ISaveParameter saveParameter = null; if (data instanceof ISaveParameter) { saveParameter = (ISaveParameter) data; IWorkItem newState = (IWorkItem) saveParameter.getNewState(); Identifier<IState> newStateId = newState.getState2(); Identifier<IState> oldStateId = null; IWorkItem oldState = (IWorkItem) saveParameter.getOldState(); |
3 answers
Ralph Schoon (63.5k●3●36●46)
| answered Jan 06 '16, 6:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jan 06 '16, 6:06 a.m.
The workshop gets the state from the "newState" and the state that the workItem in the oldState had and compares them. Similarly, you should be able to get the attribute value from the oldState and the newState and compare them.
|
Hi Ralph, do you mean that using some code like "newState->getAttribute("summary") to get "summary" new value, and use "oldState->getAttribute("summary") to get "summary" old value? I think it is the way to get attribute new and old value.
But is there any way to get the changed attributes? When save work item, how could I know which attribute is changed? If I do not have this information, I guess I should traversal all work item attributes to compare the new and old value to judge if the attribute is changed, any good way to achieve this? Comments The syntax above is incorrect. https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ shows the correct syntax. E.g.
IAttribute attribute = workItemCommon.findAttribute(projectArea, "custom.attributeID", monitor); if(attribute != null){ String old = (String)oldState.getValue(attribute,monitor); String new = (String)newState.getValue(attribute,monitor); } |
I think my question now should be "how can I know the work item attribute has changed".....
Comments Compare the values of the getValue()?
sam detweiler
commented Jan 07 '16, 8:16 a.m.
you could get the history entries which list the changed attributes, but its just as easy to run thru the list and compare..
|
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.