What other options do I have to setWorkflowAction other than relying on WorkitemOperation?
![]()
The javadoc API says:
But I don't see any examples in the Jazz biosphere that actually use it. I'm having a problem where my code to update a workitem runs with (apparently) no issue, but I'm not seeing the updates reflected on the work items.
Specifically, I'm trying to extend WorkItemOperation to change the status of a custom work item type. I can change other fields using the same code but when I try to change the workflow action, it doesn't work. Here is what I'm using:
public class UpdateWorkItemStatus implements WorkitemResultProcessor {
Because it hasn't been working, I've been doing more and more arcane things trying to get it to work, including the forbidden setState2 and now wondering what the commit is for. If the problem is that I'm doing something wrong, then my original question is wrong!
Any ideas?
- Andy
|
Accepted answer
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Jan 13 '14, 11:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Won't fit in a comment. This would be another approach:
private static String changeStatus(ITeamRepository repo, Integer workItemId, Boolean buildStatus, String actionOK, String actionKO, IProgressMonitor monitor) throws TeamRepositoryException { IWorkItemClient workItemClient = (IWorkItemClient) repo .getClientLibrary(IWorkItemClient.class); IWorkItemCommon workItemCommon = (IWorkItemCommon) repo .getClientLibrary(IWorkItemCommon.class); IWorkItem wi = workItemClient.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor); if (null == wi) { return ("work item " + workItemId + " cannot be found"); } IDetailedStatus status = null; String actionName = buildStatus ? actionOK : actionKO; IWorkItemWorkingCopyManager copyManager = workItemClient .getWorkItemWorkingCopyManager(); try { copyManager.connect(wi, IWorkItem.FULL_PROFILE, monitor); WorkItemWorkingCopy wc = copyManager.getWorkingCopy(wi); // wc.getWorkItem().getsetState2(arg0) IWorkflowInfo wfInfo = (IWorkflowInfo) workItemClient .findWorkflowInfo(wi, monitor); Identifier Andy Jewell selected this answer as the correct answer
Comments Thanks, Ralph, will try that right now. On thing I've been wondering about (since setWorkflowAction(string) was not working for me), is the action name the simple/display name of the action or is it some other underlying stringified name of the action Identifier? ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would suggest to read https://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/ to understand how that works and how to get the action.
Yes, I have that read but actually you can't tell from the article nor any other examples I've read what the literal action name is that's being passed.
However, it's a moot point because your last sample worked for me! I'm a bit disappointed because the WorkitemOperation approach is so much cleaner but the nice thing about this approach is. .. that it works! Really appreciate your help, Ralph!!
1
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As far as I can see from jumping through my blog entry it is the ID of the action. That is not necessarily the same as the display name (as usually) especially for the shipped templates. You would have to look into the process XML, unfortunately. Here an example screen shot:
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
If the last code snippet works, the operation should also work. The code below is (if you look at the WorkitemOpetration source code the same code essentially WorkItemOperation runs. The first example is, I believe, a work item operation that does exactly what you want. I think I created it as an example for exactly that purpose. If it does not work, there can be reasons as
This is great, info, thank you. I guess this code works because of the looping done to associate the action name with the action identifier whereas in my original WorkItemOperation code, I was just passing the action name. I will try updating the WorkItemOperation code with the ID and see if it works. Bahdaboom, that worked :) I'm going to file a documentation bug on this, that was a bit frustrating but thanks for your help! Why would you? This is all over the place. You can never use the name of anything. You have to find the ID. Enumeration Literals https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/ attributes https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/, wherever you look at.
I disagree, having the API reader assume a string argument is an ID, a name, a fully resolve classname, an alias, or whatever other string type is obvious is not a good practice for someone writing an API. It's a simple change and has already been made. ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Well, you can create your enhancement request.
showing 5 of 10
show 5 more comments
|
3 other answers
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Jan 13 '14, 3:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Andy, looking at it, the commit operation basically is one of the last steps in the WorkItemOperation and it saves the work item working-copies. That is about it.
If you want to change the state of the work item,you can provide the work item with a workflowAction ( .setWorkFlowAction). See http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/ for more details. There is a deprecated method .setState2() on IWorkItem that you could use to directly set a state. However, that is a bit unsafe, because you could trigger a state change that does not exist and it might also avoid all the behavior defined related to the workflow. Comments Yes, thanks, Ralph, I am using setWorkflowAction but unfortunately, it's not working and I can't figure out why. I'll have to try setState2. ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Where do you use the setWorkflowAction in the operation? This code used to work for me:
private static class WorkItemSetWorkflowActionModification extends WorkItemOperation { |
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Jan 08 '14, 3:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Andy, it would help if you describe what and where (client API/Server API) you are trying to use the API.
I only implicitly use that API. On the client I usually use a WorkItemOperation that overwrites some method as described for example here: https://rsjazz.wordpress.com/2012/08/01/uploading-attachments-to-work-items/ or here https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation. I think that eventually uses the commit() method. In the server API I use typically saveWorkItem2() or saveWorkItem3() as described in e.g. this blog: https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ Comments Yes, those articles are pretty much the basis of everything I've done... :) Will add more details to the original question. |
![]()
Updated WorkitemOperation that finds the correct action identifier based on the passed name. Not using the path as Ralph mentions above, just brute force:
@Override |
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.
Comments
How are you setting the value for the work item??
Sorry, I'm using the plain java API. I will add more details to the question.