It's all about the answers!

Ask a question

How to check if an approval Object already exists in a workitem before saving it (using java api)?


Akshata Kulkarni (37320) | asked Sep 02 '16, 12:57 a.m.
 I have created an approval Object.I need check if the workitem already has the approval Object and not save it. 

Therefore , when i create an approval Object and without saving it if i get the descriptor name as : 
approval.getDescriptor().getName() it returns null

Is there any way i can check if an approval object already exists in the workitem using java api?

Thanks in advance!

One answer



permanent link
Parveen Patel (771427) | answered Sep 02 '16, 4:29 a.m.

Hi,

You need to write operation advisor, below is my working code to check review type approval:

IApprovals approvals = workItem.getApprovals();

final String reviewType="com.ibm.team.workitem.approvalType.review";

final List<IApproval> approvalList = approvals.getContents();

for(IApproval approval :approvalList){

IApprovalDescriptor appDesc = approval.getDescriptor();

String approvalTypeNew = appDesc.getTypeIdentifier();

if(approvalTypeNew.equalsIgnoreCase(reviewType)){

return;

}else{

IAdvisorInfo info = collector

.createProblemInfo(

"Required Approval of type 'Review' is not present",

"Please add Approval of type 'Review'",

"error");

collector.addInfo(info);

}

}

You may check all the information of approval i.e. Approval title, state of approval. Please refer below link on jazz.net:

https://jazz.net/library/article/1118

Your answer


Register or to post 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.