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();
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
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?
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); }
That would be my approach.
I think my question now should be "how can I know the work item attribute has changed".....
Comments
Compare the values of the getValue()?
you could get the history entries which list the changed attributes, but its just as easy to run thru the list and compare..
from my dump workitem attributes sample code here
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
for (IAttribute ia : workItemCommon.findAttributes(projectArea,
monitor))