Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Script listener on Issue watcher added event

Hello,

I've been trying to set up a listener, which would send e-mail notification to a watcher when he is added to an issue (kind of like request participant notification for customers).

I have tried 2 listeners:
- Send a custom mail

- Fires an event when condition is true

 

In both cases: When I leave the condition blank, the listener won't run. When I add a condition for a project key, it runs and then shows this:

Cannot cast object 'com.atlassian.jira.event.issue.IssueWatcherAddedEvent@cc2c2bfd' with class 'com.atlassian.jira.event.issue.IssueWatcherAddedEvent' to class 'com.atlassian.jira.event.issue.IssueEvent'

 

3 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 12, 2018

Hello @Karolína Vavříková

Can you please share screenshot of the configuration and code, as it seems you are trying to cast the WatcherAddedEvent object to IssueEvent.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 12, 2018

Because if you see here

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/event/AbstractEvent.html

The classes IssueEvent and IssueWatcherAddedEvent are parallel in hierarchy under AbstractEvent class and thus can't be cast

well, that's...nice... So how do I bypass that?screencapture-jira-elx-cz-plugins-servlet-scriptrunner-admin-listeners-edit-1515036321-2018-10-12-14_32_18.png

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 12, 2018

If you leave it blank then you say that it's not running, do you have something from the logs?

Because from the original error msg if you have some condition and you get the error

Cannot cast object 'com.atlassian.jira.event.issue.IssueWatcherAddedEvent@cc2c2bfd' with class 'com.atlassian.jira.event.issue.IssueWatcherAddedEvent' to class 'com.atlassian.jira.event.issue.IssueEvent'

It more or less seems like a bug in the internal working of the plugin as you are not explicitly casting the issue object.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 15, 2018

Hello @Karolína Vavříková

Did you try creating a request in the Adaptavist support portal for this issue.

Hi,  not yet. I have found out that we have an update pending, so I will test it first. Thank you for your help, though!

How can I solve problem?

Hi @huw@Tarun Sapra

I have filed a bug, however, I don't have any good news. Adaptavist agent told me this:

it looks like the 'Fires an event...' listener has the same underlying restriction as the custom email listener, just buried more deeply in the implementation. I will file a development ticket to see whether this restriction can be lifted, or at least more explicitly outlined in the documentation.

 

I have asked how to bypass that and achieve desired result, but no answer yet.

aand the reply follows:

One way you could do it would be to set up a custom scripted listener on the IssueWatcherAddedEvent and in the script, fetch the watcher's email address (event.applicationUser.emailAddress) and send a message to it via the MailQueue

Thanks for the update. 

We have exactly the same use case and error. Did you plugin/app update cure it? 

Hi @huw, unfortunately, update didn't work, still the same issue.
I filed a bug in Adaptavist customer portal.

The custom email listener is currently not compatible with events other than IssueEvent
the other option should be working, though, so they are looking into it.

I will keep you updated

TAGS
AUG Leaders

Atlassian Community Events