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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,120
Community Members
 
Community Events
185
Community Groups

Add watchers at issue creation

Oliver Smith
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 10, 2022

Hello, i get an error in logs my post-function (in Workflow)

my code :

import com.atlassian.jira.component.ComponentAccessor

def watcherManager = ComponentAccessor.getWatcherManager()

def userManager = ComponentAccessor.getUserManager()

def watchUsers = {usernames ->

    usernames.each {

        def user = userManager.getUserByKey(it.toString())

        watcherManager.startWatching(user, issue)

    }

}

def users = ["n.lubyanskaya", "a.belyaeva","e.fedoseeva", "e.dushnova", "l.golovanova", "a.zaretskaya","v.moshkarova","a.zamekhovskaya","e.kozhukhova"]

watchUsers(users)

What could be the problem ?


logs:
 

2022-06-10 11:18:51,737 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,817 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,888 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,928 ERROR [watchers.DefaultWatcherManager]: You must specify a user.
2022-06-10 11:18:51,962 ERROR [watchers.DefaultWatcherManager]: You must specify a user.

 

1 answer

1 accepted

1 vote
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 10, 2022 • edited

Hi @Oliver Smith  Kindly use following script for adding multiple users as watcher, update usernames as per your requirement :- 

Kindly move scripted post function after "Creates the issue originally." post function, if you are applying script on create issue transition.  

import com.atlassian.jira.component.ComponentAccessor

def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()

def watcher = ["username1","username2"]

watcher.each{userName->
def user=ComponentAccessor.userManager.getUserByName(userName)
watcherManager.startWatching(user, issue)
}

 Thanks

V.Y

Oliver Smith
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 10, 2022

@Vikrant Yadav  , thank you very much, everything works! Have a nice day! :)

Like Vikrant Yadav likes this
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 10, 2022

You’re Welcome 😇 Have a great weekend 

Like Oliver Smith likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events