Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add mention in comment to watchers/participants

Bartek dro
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 4, 2024

Hi,

How can i automatically add some user as participant or watcher on issue if i @mention them in comment ?

1 answer

0 votes
Florian Bonniec
Community Champion
January 4, 2024

Hi @Bartek dro 

 

You should be able to do it using Scriptrunner, maybe automation for JIRA as well.

For Scriptrunner it would be a listener on MentionIssueCommentEvent:

 

event.getToUsers()*.getUsername()
Regards
Bartek dro
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 5, 2024

Could you show me what the entire script will look like?
I'm a total beginner.

Florian Bonniec
Community Champion
January 8, 2024

Hi

 

I do not have currently any instance to do some test.

 This script should do what you are loking for.

import com.atlassian.jira.user.util.UserManager

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.watchers.WatcherManager

WatcherManager watcherManager = ComponentAccessor.getWatcherManager()

UserManager userManager = ComponentAccessor.getUserManager()

event.getToUsers()*.getUsername().each{ userNameMentioned ->

        ApplicationUser userMentioned userManager.getUserByName(userNameMentioned)

        if(userMentioned){

            watcherManager.startWatching(userMentioned, event.getIssue())

        }

}

 

Regards

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events