How use work item API to add approvals?
3 answers
Hi Jia,
clients can use this code:
Please note the type of the approval is controlled using the REVIEW_TYPE.
clients can use this code:
private void createApproval(IWorkItem newState,
IAdvisorInfoCollector collector) throws TeamRepositoryException {
IContributorHandle owner = newState.getOwner();
IContributorHandle approver = null;
approver = getApproverExternalByOwner(owner);
// getApproverFromTeamHierarchy(owner,newState);
if (null == approver) {
IAdvisorInfo info = collector.createProblemInfo(
"Unable to create the Approval",
"Unable to find an approver for the work item", ID);
collector.addInfo(info);
return;
}
IApprovals approvals = newState.getApprovals();
IApprovalDescriptor descriptor = approvals.createDescriptor(
WorkItemApprovals.REVIEW_TYPE.getIdentifier(), APPROVAL_NAME);
IApproval approval = approvals.createApproval(descriptor, approver);
approvals.add(approval);
}
Please note the type of the approval is controlled using the REVIEW_TYPE.