Custom Issue Commented Event


I'm trying to setup a custom event with template Issue Commented that is thrown (through a Script Listener) when a Issue Commented event is thrown, except for comments added by a specific user.


I've created the new event like:

Task Commented              => Template = Issue Commented


...and I've added the related Script Listener:

Project: XXX

Event: Issue Commented


import com.atlassian.jira.component.ComponentAccessor
if (comments) {
    //return comments*.authorKey[-1] == "Anonymous"
    return ComponentManager.getCommentManager().getComments(issue).last().author == "Anonymous"
} else {
    return false

Event: Task Commented


I've associated to the new event the requested notifications and then had a test.

The result is:

Task Commented notification arrives but it has no comment in it's body:



If I do the same test enabling notifications for event Issue Commented (the original one) I get the notification with the comment within it's body.


Why this?

How can I reach the requested result?

Thank you in advance


4 answers

1 accepted

I actually think there is an issue here. There is a built-in script called something like "Fire a comment when..." that you can use to raise an event but only under specific circumstances.

If you choose the Issue Comment event, then the event is raised, but the vm mail templates try to get the comment from the event, but the event was raised without attaching any comment to it.

I think this is probably a bug.

Recently I posted an answer on how to use a custom script to raise an Issue Commented event that attaches the most recent comment: Note that my original answer is not correct, the correct answer is in a gist in the comment.

Hi @Arianna Fabbri,

Is there any reason why you cannot use directly the System Issue Event? According to the condition from your code, you could simply configure that event to trigger that event for the "Single User" called Anonymous.

Custom events are mainly used to generate notifications for custom workflow transitions.

Hi @Alejo Villarrubia [Adaptavist]

I need to distinguish between internal comments (added by users directly from Jira) and comments added via email from Anonymous user.

I created a custom Task Internal comment Event and I would like to trigger the custom event only if the comment is added not by Anonymous (in the above condition I've made an error, it must be != "Anonymous").

In this way I can associate to the custom event, in the notification scheme, the users that have to receive notification for all the internal comment (not added from Anonymous)

Thank you

Hi @Jamie Echlin [Adaptavist]

thank you for your answer but I think that my case is a little bit different: I have to catch (in addition to generic events for which your link is very useful) all the standard Issue Commented event and distinguish from who it has been added and then decide if I have to notify it to the users or not...

How can I do that?

Thank you

It's really the same question... you already have your condition, then you use the script to raise a new event, called eg Issue Anonymously Commented, which you catch in your notification scheme.

Passing, wile raising it, the comment just added. Perfect, now I have understood. Thank you very much

I've been taking a look at @Jamie Echlin [Adaptavist] answer and that is definitely the correct one.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in United States

Administrators Cleanup

Good morning, After a long weekend cleaning up, I am still in the cleanup mode 😊. I am curious to know: When do you feel the urgency to cleanup your Atlassian Tools? How many times do y...

47 views 1 1
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you