We're using scriptrunner, and I'd like to custom script a post function to do this. I've given it a shot, and I'm not getting the watchers, but there are no errors.
Here's the most recent version of the script...
import com.atlassian.jira.component.ComponentAccessor
log.debug "In WATCHER Script"
def CustomFieldManager = ComponentAccessor.getCustomFieldManager()
def websiteCustomField = CustomFieldManager.getCustomFieldObjectByName('Website')
def websiteValue = issue.getCustomFieldValue(websiteCustomField)
log.debug 'websiteCustomField is' + websiteCustomField
log.debug 'websiteValue is ' + websiteValue
if(websiteValue == '[Oracle Commerce Backend]') {
def watcherManager = ComponentAccessor.getWatcherManager()
def userManager = ComponentAccessor.getUserManager()
watcherManager.startWatching(userManager.getUserByKey('user1'), issue)
watcherManager.startWatching(userManager.getUserByKey('user2'), issue)
log.debug('user1 and user2 should be watchers')
}
Hello,
I guess you are not entering the if condition. Are you sure that you enter the if condition? Specifically [Oracle Commerce Backend] does not look right for comparison. Does it mean that the websiteValue is a List? what is the type fo the Website custom field?
If websiteValue is a list, your comparison should look like this:
websiteValue.first() = 'Oracle Commerce Backend'
or you can try
'Oracle Commerce Backend' in websiteValue
Hi,
You can try below free add on which help you to add watchers at the creation of the request.
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.