It's all about the answers!

Ask a question

How use work item API to add approvals?


Jia Jia Li (8057133190) | asked Apr 24 '12, 9:54 a.m.
Any one can provide some code sample for adding work item approval ?

Thanks very much!

3 answers



permanent link
Ralph Schoon (59.7k23643) | answered Apr 25 '12, 6:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Jia,

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.

permanent link
Jia Jia Li (8057133190) | answered May 02 '12, 8:41 a.m.
Thanks very much! I will have a try for that.

permanent link
Chris McKenna (31133) | answered Jul 25 '12, 9:51 a.m.
 I am very new to this.  Where/How does one use this?

Your answer


Register or to post your answer.