It's all about the answers!

Ask a question

How Can I See Which Attributes are Changing in a Server-Side Pre-Condition?


Nate Decker (37814761) | asked Jan 05 '15, 4:45 p.m.

In our process, we disallow changes to work items once they have entered a "closed" state. In addition, only certain power users are allowed to re-open closed work items. One of our users has requested that we provide a means for them to add comments to closed work items, but continue to restrict all other changes.

We think the best way to support this would be to create a server-side pre-condition operation behavior that checks on work item save to see if the only change is an added comment. I'm unsure how to do this. I think I know how to check whether a specific attribute has changed by comparing the old state and the new state, but I have two issues with that approach:
1) I'm paranoid that it only works on follow-up actions, not pre-conditions.
2) I can't explicitly validate a list of work item attributes because that would make the code really complex and hard to maintain.

Is there a way to see what exactly changed in a work item without explicitly checking a specific attribute? Ideally, I'd like to get an enumerated list of changes.

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Jan 05 '15, 5:53 p.m.
edited Jan 06 '15, 4:44 p.m.
1. works for pre-conditions
2. far as I know, there is no list of just changes

but you could make a list pretty easily..
from the oldState get the list of attributes
WorkItemServer.findAttributes(projectArea, monitor) - have to load access to the IWorkItemServer service
then loop thru the old-state workitem (hasAttribute == true)
  compare attribute old = new
     if not equal, add to a list collection
     if handles compare UUIDs for equal

once done, then process the list
Nate Decker selected this answer as the correct answer

Comments
Nate Decker commented Jan 06 '15, 8:37 a.m.

Thanks. That is helpful. I'll try to head down that route and if I'm successful, I'll come back and mark this answer as accepted.


sam detweiler commented Jan 06 '15, 8:41 a.m.

and u can see how to handle different attributes here in my utility that dumps the attributes of workitems found in a query result list (accepted answer)
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes

function
static void printAttributes(IWorkItem workItem,

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.