It's all about the answers!

Ask a question

Create Workitem approvals - through Operation advisor (Error Faced)


VK L (8177136159) | asked Jul 10 '12, 6:56 a.m.
retagged Jul 10 '12, 4:43 p.m. by Millard Ellingsworth (2.5k12431)
Hi All,
               I created an Operation advisor for approval item creation. I am not sure how to add certain users to the approval. How to fetch the contributor handle for the users to be added? My snippet is as below:

IApprovals approvals= sourceworkItem.getApprovals();

                IApprovalDescriptor descriptor= approvals.createDescriptor(WorkItemApprovals.APPROVAL_TYPE.getIdentifier(), "Lead Developer Approval");
                     IApproval approval= approvals.createApproval(descriptor, contributorHandle);
                                            approvals.add(approval);

When i try to save the WorkItem i get the below error:


Thanks.

4 answers



permanent link
sam detweiler (12.4k6180201) | answered Aug 05 '12, 8:22 a.m.
using the ITeamRepository() you get the contributorManager

  IContributorManager contributorManager()
          Returns an object for creating and updating contributors (and teams) in this repository.

should also say 'locating'

then you can use the contributorManager() to search for users.

Sam

permanent link
Filip Wieladek (30413) | answered Aug 30 '12, 4:19 a.m.
Hi there,

I am still not sure on what exactly you wish to accomplish, but I will try to answer your question to the best of my abilities.

Just as a quick note, Operation Advisors are run on the server, therefore you should not be using the client interface, as suggested in sam's answer, but rather use the IContributorService.

To use the IContributorService, make sure that your advisor extends AbstractService and then you can do the following in your code:

   IContributorService contributorService= getService(IContributorService.class);
   contributorService.fetchContributorByUserId(userId);

That was the good news. The bad news however is that operation advisors are not allowed to modify the work item state:
 * Operation advisors are run before an operation is invoked to decide whether
 * or not the operation should be executed. Advisors check conditions and
 * report problems via the collector they are given. If an advisor reports a
 * serious problem with an operation, the operation will not be executed (though
 * subsequent advisors may still be checked).
 * 
 * Advisors may not make modifications to data which is persisted in the
 * repository. Clients wishing to participate in operations by modifying data
 * should implement an {@link IOperationParticipant} instead.


permanent link
VK L (8177136159) | answered Sep 03 '12, 1:52 a.m.
Hi All,
           I have resolved this error and it works fine now. It was due to some problem with the approval item creation and addition of approvers to it.

Thanks.

permanent link
Marcos Sánchez (19511) | answered Apr 29 '13, 12:00 p.m.
Hi Valli L,

Can you show me the succesfull code?

Thanks.

Your answer


Register or to post your answer.