By a bulk operation I'd like to add a watcher to a list of issues.It seems I can only add myself as watcher to this list.Is there a way to add others than myself?
@Paul van Erp You can use this script:Just follow this steps:~First change user and user2 (user2 is watcher)~Second change query (JQL)//-----------------------------------------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.search.SearchProviderimport com.atlassian.jira.jql.parser.JqlQueryParserimport com.atlassian.jira.web.bean.PagerFilterimport com.atlassian.jira.user.ApplicationUser
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)def searchProvider = ComponentAccessor.getComponent(SearchProvider)def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()//EDIT THIS USERdef user = userManager.getUserByName("jamil.rahimov")
// Edit this query to suitdef query = jqlQueryParser.parseQuery("project = SD AND issuetype = \"Service Request\" AND status = \"In Progress\"")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
log.debug("Total issues: ${results.total}")
//TYPE WATCHER ID FOR ADDING TO THE ISSUEApplicationUser user2 = userManager.getUserByName("admin")
def watcherManager = ComponentAccessor.getWatcherManager()
results.getIssues().each {documentIssue ->log.debug(documentIssue.key)
// if you need a mutable issue you can do:def issue = issueManager.getIssueObject(documentIssue.id)if (user2)watcherManager.startWatching(user2, issue)
}
It looks like you're new here. Sign in or register to get started.