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.
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.
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.
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
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
you need to GET their contributor (user) record.
if they are not registered, you cannot add them to a workitem..
I am doing that only.
Please let me know if I am doing some thing wronIContributor userIAG = (IContributor) IContributor.ITEM_TYPE.createItem(); userIAG.setUserId("myuserid");
and adding that contributor to the subscriber.
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
u need to use the IContributorManager class to find the user entry, from the javadoc
IContributorRecord
|
fetchContributorRecordByUserId(IContributorUserId userId, org.eclipse.core.runtime.IProgressMonitor monitor)
Fetches a contributor record by one of its user ids. |