Hi All
We have a custom field to store product information. Whenever a user creates an issue related to a bug, we hope to automatically add the corresponding leader as watchers according to the field value. I have looked at other documents in the community, but there seems to be no relevant solution
The jira we are using is the server version, and the corresponding Project automation does not have the option of managing watchers. I am trying to solve this problem using scriptrunner, but I am not sure how to get or assign the value to watchers
Hello @arno ,
If you could provide us with more information on your requirements, it would greatly help us to provide a better solution.
For example:-
From what we can see, Jira Automation for Data Center does provide an action to manage Watchers:-
You should be able to manage your Watchers after configuring additional conditions.
If you would like to use ScriptRunner instead, you can configure a Custom script post-function [ScriptRunner] in your workflow with the below draft script:-
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager()
def watcherManager = ComponentAccessor.getWatcherManager()
def productInformationCF = customFieldManager.getCustomFieldObject('customfield_xxxxx') //ProductInformation
def productInformationValue = issue.getCustomFieldValue(productInformationCF)
def user
if(productInformationValue.equals("A")) {
user = userManager.getUserByName('charlie')
} else if(productInformationValue.equals("B")){
user = userManager.getUserByName('alpha')
} else {
user = userManager.getUserByName('beta')
}
watcherManager.startWatching(user, issue)
Hope this helps.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.