Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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();

0 votes



3 answers

Permanent link
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.

0 votes


Permanent link
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?

0 votes

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.


Permanent link
I think my question now should be "how can I know the work item attribute has changed".....

0 votes

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))

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jan 06 '16, 5:50 a.m.

Question was seen: 3,185 times

Last updated: Jan 07 '16, 8:16 a.m.

Confirmation Cancel Confirm