Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes


Accepted answer

Permanent link
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

0 votes


3 other answers

Permanent link
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);

   

                       

0 votes

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.

IContributor userIAG = (IContributor) IContributor.ITEM_TYPE.createItem();
userIAG.setUserId("myuserid");

and adding that contributor to the subscriber.

Please let me know if I am doing some thing wron g


Permanent link
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

IContributorRecord fetchContributorRecordByUserId(IContributorUserId userId, org.eclipse.core.runtime.IProgressMonitor monitor)
          Fetches a contributor record by one of its user ids.


0 votes


Permanent link
Sam,

Thanks for guiding me in right direction.
As I am using the Server side plugin, I have achieved the functionality using

IContributorService#fetchContributorByUserId.

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Oct 23 '12, 8:06 a.m.

Question was seen: 5,121 times

Last updated: Apr 30 '13, 12:18 p.m.

Confirmation Cancel Confirm