Create Workitem approvals - through Operation advisor (Error Faced)
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.
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
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
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:
That was the good news. The bad news however is that operation advisors are not allowed to modify the work item state:
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.