How to get the "Filed Against" value from RTCJavaP
![]()
I need to get the "Filed Against" value from RTC by using java plain api. I wrote following code:
IAttribute component= workItemClient.findAttribute(projectAreaHandle, IWorkItem.CATEGORY_PROPERTY, monitor); This does not work, is there someone can help on this? Thanks a lot! |
Accepted answer
![]()
Ralph Schoon (62.0k●3●36●43)
| answered May 24 '19, 9:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER I would suggest to look here: https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ Ralph Schoon selected this answer as the correct answer
|
4 other answers
![]()
here is customizing code about plain jave api support by ibm.
how to get category name about workitemId IProgressMonitor monitor = new SysoutProgressMonitor(); ITeamRepository repo = Snippet1.login(monitor); IItemManager itm = repo.itemManager(); IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class); IWorkItem workItem = service.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor); ICategory category = (ICategory) itm.fetchCompleteItem(workItem.getCategory(), IItemManager.DEFAULT, monitor); System.out.println("This is category: " + category.getName()); |
![]()
I need to check the existing value of "Filed Against" value and then set it to new value.
Appriciate any suggessions or Piece of code. Thanks in Advance Radhika Bandari |
![]() I need to check the existing value of "Filed Against" value and then set it to new value. public static void main(String[] args) { TeamPlatform.startup(); try { IProgressMonitor monitor = new SysoutProgressMonitor(); ITeamRepository repo = Snippet1.login(monitor); // update workItem values updateWorkItem(repo, 69, monitor); } catch (TeamRepositoryException e) { System.out.println("Unable to login: " + e.getMessage()); } finally { TeamPlatform.shutdown(); } } public static IWorkItemHandle updateWorkItem(ITeamRepository repo, int workItemId, IProgressMonitor monitor) throws TeamRepositoryException { IItemManager itm = repo.itemManager(); IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class); IWorkItem workItem = service.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor); //get existing category value. ICategory category = (ICategory) itm.fetchCompleteItem(workItem.getCategory(), IItemManager.DEFAULT, monitor); System.out.println("This is category: " + category.getName()); // ready new category value. List<String> path= Arrays.asList("JUnit/Tests".split("/")); ICategoryHandle newCategoryHandle = service.findCategoryByNamePath(workItem.getProjectArea(), path, monitor); IWorkItemWorkingCopyManager wcm = service.getWorkItemWorkingCopyManager(); wcm.connect(workItem, IWorkItem.FULL_PROFILE, monitor); try { WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem); // set new category value. wc.getWorkItem().setCategory(newCategoryHandle); //String actionName = "com.ibm.team.workitem.defectWorkflow.action.startWorking"; String actionName = "modify"; wc.setWorkflowAction(actionName); System.out.println(wc.getWorkflowAction()); IDetailedStatus s = wc.save(monitor); if (!s.isOK()) { throw new TeamRepositoryException("Error saving work item", s.getException()); } } finally { wcm.disconnect(workItem); } return workItem; } |