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

Why my script doesn't work with Issue type ?

Alex
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.
September 13, 2022
import com.atlassian.jira.component.ComponentAccessor

def issueType = issue.getIssueType().getName()

def array_issue_type = ["issue_type1","issue_type2","issue_type3","issue_type4"] as String

for(arr in array_issue_type) {

if (issueType == arr){

def userManager = ComponentAccessor.getUserManager()

def watcherManager = ComponentAccessor.getWatcherManager()

def watcher = ["username"]

watcher.each{userName->

def user=ComponentAccessor. userManager.getUserByName(userName)

watcherManager.startWatching(user, issue)

}
}
}

1 answer

1 accepted

4 votes
Answer accepted
Radek Dostál
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.
September 13, 2022

You're declaring an array but immediately casting it into String, so the for loop never executes.

Alex
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.
September 13, 2022

Hi! @Radek Dostál Yes exactly! thank you very much

Alex
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.
January 27, 2023

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events