Remove user from watchers in post function or listener

Eryk Leniart May 10, 2017

Hello,

In workflow create action I have post function which adds specific user to watcher list (service user). Goal is to enable sending email notifications about created issue to group of people (mailing list).  I wanted to first add this service user as a watcher and than after email notification is sent remove the user from watcher in order to avoid receiving spam.

The problem is that I can't force JIRA to remove user from watchers in post function (after firing JIRA issue created event) or in script listener (event Issue Created). stopWatching(user, issue) function just doesn't work. Moreover getWatchersUnsorted(issue) function gives me list of watchers (my service user is present in that list), but when I run isWatching(user, issue) method with my user it always returns false.

I also tried to programmatically reindex issue but this also didn't work.

Any ideas? Thanks,

1 answer

0 votes
Thomas Schlegel
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2017

Hi Eryk,

why don't you put them all in a self defined group and add the notification to that group in the notification scheme to the event "Issue Created"?

 

Eryk Leniart May 10, 2017

Hi Thomas,

Because I want to avoid managing those groups (new hires etc.) as an administrator.

Thomas Schlegel
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2017

but adding and removing users to/from the "add-and-remove-watchers-function" is also an administrative effort ;-)

Eryk Leniart May 10, 2017

You've got a point there :) But I also want to send those emails for specific issue types i.e. only Defects for one project, Story for another.

Suggest an answer

Log in or Sign up to answer