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

How to close work item: setResolution2? How to use?

Is there any sample code for how to "close" a work item from a plain java client?  Probably I mean "resolve".

(In my way of thinking, I simply want to "change state" of the work item, but the most obvious API IWorkItem.setState2(...) is deprecated.)

Browsing the JavaDoc I find IWorkItem.setResolution2(Identifier<IResolution> value)

This looks likely to be what I need, but I can't see how it is to be used.

I guess a lot of Q&A could be reduced if there were more samples.  Thank you.  Sorry if it's there and I just missed it, but I did look.  There is one similar-looking previous post https://jazz.net/forum/questions/15954/how-to-move-a-work-item-to-close-state-programmatically but it talks about something named WorkItemServer but nothing like that is listed in the PJC JavaDoc.

Thank you.

0 votes


Accepted answer

Permanent link
IWorkItem.setResolution2(Identifier<IResolution> value) is - as far as i can tell - not what you are using to close a work item. This is probably only intented to set the resolution code to the resolution of the work item workflow state (the thing that shows right to the state e.g. 'Invalid', 'Works for me' or 'Won't fix').

As described in http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/ you have to bring the work item into a closed state e.g. into the resolved state, if your workflow has one. As described in the same article the workflow contains means to access the resolution action using
workflowInfo.getResolveActionId();
However, you have to bring the work item in a state where you can use it first, by using workflow actions available in the state you are. Again, I tried to explain that in the articles mentioned. Once you are in the state you want to be, you can set the resolution as well, using your code above and a valid resolution identifier.

Code to analyze the workflow and get a series of transitions is in http://rsjazz.wordpress.com/2012/11/27/resolve-parent-if-all-children-are-resolved-participant/

There used to be a setState2() method in the client API that you were able to set an arbitrary state regardless of where you were, but that was deprecated the last time I saw. The reason probably being that you would be cheating and violate the workflow, if there was no transition available from your current state to the target state.

Hope this helps.
Martin Gompertz selected this answer as the correct answer

0 votes

Comments

Thanks Ralph.  In fact I succeeded when I noticed in your first link (the same one posted by Millard) there was a section suggesting how to use the API from a plain client.

How nice it would be if the workitem API contained a .close() method.  That function is what I have just had to write myself.

Anyway, the job is done now, and thank you.  It would have taken much longer without your helpful articles.


One other answer

Permanent link
While the other post is older, it likely points to the correct path. I doubt setResolution2() is what you want as a resolution is a "sub-state", if you will. For example, if an item is Closed, Fixed, Closed is the state and Fixed is the resolution (available because Closed is a resolved state). 

A work item is going to have a defined workflow -- a collection of states and transitions (actions) that move between the states. Ideally, you want to respect that (RTC may even require you to). Programatically, it may be possible that Resolved is not available from whatever state the work item is currently in. Ralph Schoon's blog is worth reading (and re-reading) if you want to work the the Plain Java Client API. Here's one of his posts on manipulating work item states.]]

Millard

1 vote

Comments

I checked Ralph's blog before posting here (I always do, it's a good resource), but I seem to have missed that article you linked.  I'll read more and post again.  Thanks!!

Deleted. Still working.

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: May 08 '13, 7:47 p.m.

Question was seen: 4,977 times

Last updated: May 16 '13, 9:11 a.m.

Confirmation Cancel Confirm