Create Workitem approvals - through Operation advisor (Error Faced)
VK L (817●7●157●159)
| asked Jul 10 '12, 6:56 a.m.
retagged Jul 10 '12, 4:43 p.m. by Millard Ellingsworth (2.5k●1●24●31)
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
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 |
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. |
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. |
Hi Valli L,
Can you show me the succesfull code? Thanks. |
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.