How to delete workitem programmatically
Pheneenda gadipoodi (1●1●7●10)
| asked Feb 03 '14, 5:25 a.m.
retagged Feb 04 '14, 7:07 a.m. by Adam Wereszczynski (928●1●19●32) Hi, I want to delete work item using plain java api. I have used "WorkItemClient.deleteWorkitem()" method but it is not deleting the workitem. Refer below code, I have tried passing both workitem and workitem workingcopy
IWorkItem workItem = workItemClient.findWorkItemById(Integer.parseInt(workItemId), IWorkItem.FULL_PROFILE, null);
and
IWorkItem workItem = workItemClient.findWorkItemById(Integer.parseInt(workItemId), IWorkItem.FULL_PROFILE, null);
|
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Feb 18 '14, 6:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 18 '14, 6:51 a.m.
This code works for me, provided the user has the permission to delete work items in the project area.
IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.SMALL_PROFILE, monitor); IDetailedStatus status = workItemClient.deleteWorkItem(workItem, monitor); if (!status.isOK()) { throw new TeamRepositoryException("Error deleting work item", status.getException()); } System.out.println("Deleted work item: " + idString + ".");You don't require a workingcopy, workingcopy manager or anything else. Comments
Pheneenda gadipoodi
commented Feb 18 '14, 10:37 a.m.
Thanks Ralph.
|
Hi,
Are you getting any errors? I believe the user who deletes work items needs to have JazzAdmins permissions. Can you confirm the user who is authenticated has JazzAdmins permissions? Comments
Pheneenda gadipoodi
commented Feb 03 '14, 11:02 p.m.
Thanks for your quick response Yes, I have admin rights and I am able to delete the workitems using eclipse. However I am not able to delete using the java program, in program I am getting status OK when I try to execute delete instruction(workItemClient.deleteWorkItem(workItem, null)). After that I am not able to fetch that workitem using Java API method(workItemClient.findWorkItemById(Integer.parseInt(workItemId), IWorkItem.FULL_PROFILE, null)), however able to fetch using workitem query in RTC eclipse and also fetch workitem using quick search also. Unfortunately, I'm not familiar enough with the delete api to understand why it wouldn't be working. Perhaps something in this article on creation will trigger something for you: https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation.
Pheneenda gadipoodi
commented Feb 18 '14, 4:29 a.m.
Thanks for your prompt response. I have already went through that page however I did not find anthing related to delete workitems please guide me to get the proper point of contact. @rschoon do you have any ideas?
sam detweiler
commented Feb 18 '14, 10:54 a.m.
many time the eclipse client caches things u don't wan it to..
close eclipse and reopen
note that the pgm connection and the eclipse connection to the workspace are two different connections.
|
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.