Modify a WorkItem
I have tried to look around for this and never really found something that helped me.
I have a WorkItemID (like 33338) and I want to change a single attribute programmatically. final ITeamRepository repository = app.login (); final IWorkItemClient workItemClient = app.clientLibrary (IWorkItemClient.class); for (final String arg : args) { System.out.println("looking up work item " + arg); final IWorkItem workItem = workItemClient.findWorkItemById(Integer.parseInt (arg), IWorkItem.FULL_PROFILE, app.getMonitor ()); WorkItemWorkingCopy workingCopy = (WorkItemWorkingCopy)workItem.getWorkingCopy(); final List<IAttribute> attributes = app.getAttributes (workItem); for (int i = 0; i < attributes.size (); i++) { IAttribute attr = attributes.get(i); System.out.println(attr.getIdentifier()); if (attr.getIdentifier().equals("sort")){ workItem.setValue(attr,new Integer("99999")); } } IDetailedStatus status = workingCopy.save(app.getMonitor ()); I was hoping this work work, since it is similar to what I used to programmatically create work items. However, I get a classCastException on this line: WorkItemWorkingCopy workingCopy = (WorkItemWorkingCopy)workItem.getWorkingCopy(); But if I keep it as IWorkItem workingCopy = (IWorkItem)workItem.getWorkingCopy(); Then my workingCopy.save(monitor) method doesn't exist. Susan |
3 answers
Ralph Schoon (63.5k●3●36●46)
| answered Apr 04 '11, 4:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Susan,
after a bit of searching this forum the following code does the trick for me:
I followed some links in http://jazz.net/forums/viewtopic.php?t=15608 and had some ancient code. Thanks, Ralph I have tried to look around for this and never really found something that helped me. |
|
The disconnect on the work item here is key ...thanks! Could not find that anywhere!
|
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.