How to remove every approval from a work item in java?
I am currently writing an operation behavior that removes all approvals from a work item when the work item is moved back to another state. My operation behavior so far does not remove any of the approvals from the work item. Here is the code I currently have for removing approvals.
public void removeApprovals(IWorkItem currentWorkItem) throws TeamRepositoryException {
IApprovals approvals = currentWorkItem.getApprovals();
List<IProval>approcalConent = approvals.getContents();
for(IApproval approval: approvalContent) {
IApprovalDescriptor descriptor = approval.getDescriptor();
approvals.remove(approval);
approvals.remove(descriptor);
}
}
Is there something I am missing or doing wrong when it comes to deleting approvals?
One answer
This is the client API https://rsjazz.wordpress.com/2012/10/01/adding-approvals-to-work-items-using-the-plain-java-client-libraries/
and this is the server API: https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ it shows creation, but should provide a good idea how the API works.
You need a working copy and/or use a workitem operation. You need to save the items, including the work item.