How to delete workitem programmatically
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);
IDetailedStatus status = workItemClient.deleteWorkItem(workItem, null);
and
IWorkItem workItem = workItemClient.findWorkItemById(Integer.parseInt(workItemId), IWorkItem.FULL_PROFILE, null);
IDetailedStatus status = workItemClient.deleteWorkItem((WorkItemHandle) workItem.getWorkingCopy(), null);please let me know if I am doing anything wrong.
2 answers
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?
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
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.