How to add and remove subscriber in a same Operation particpant?
Hai.
I have a peculiar requirement. I want to send alert notification mail to an user by adding him in the subscriber list based on a certain custom attribute and status of the Task. Once the status change notification sent to the User, I want to unsubscribe him immediately. Because, other changes happening in the work item or not interested for them. How to achieve this? Help appreciated. |
Accepted answer
at the time the participant is called, the workitem as been saved already.
so you will have to add the user as a subscriber, and save the workitem again, which will call the participant again (so you need to set some flag to know this) then you need to remove them as a subscriber, and save the workitem AGAIN.. which will call the participant again. of course, I do not know if this will cause an email to be queued to send, as I don't know the internal timing of the calls. Muthukumar C selected this answer as the correct answer
|
3 other answers
Thanks Sam.
I did the exact thing. I used SaveWorkitem3 method to send the additional parameter to avoid recursion. But the thing is that the subscription is not happening. I removed the code for remove the subscriber and checked. user is not added as the Subscriber. I am having the User ID as string. So I tried the following but no luck sourceWorkItem = (IWorkItem) workItemServer.getAuditableCommon().resolveAuditable(sourceWorkItem ,IWorkItem.FULL_PROFILE,monitor).getWorkingCopy(); IContributor userIAG = (IContributor) IContributor.ITEM_TYPE.createItem(); userIAG.setUserId("myuserid"); ISubscriptions subscription= sourceWorkItem.getSubscriptions(); subscription.add(userIAG); workItemServer.saveWorkItem3(sourceWorkItem, sourceWIRef, null, additionalParams); Comments
sam detweiler
commented Oct 23 '12, 9:38 a.m.
you need to GET their contributor (user) record.
I am doing that only.
Please let me know if I am doing some thing wron
g
|
U are creating a user entry in memory, not looking a user up in the system.
u need to use the IContributorManager class to find the user entry, from the javadoc
|
Sam,
Thanks for guiding me in right direction. As I am using the Server side plugin, I have achieved the functionality using IContributorService#fetchContributorByUserId. |
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.