Our engineering group would like to un-watch tickets that they move over to QA. The problem is that the current assignee needs to move the issue over to the new workflow step that indicates that the issue is ready for QA. The problem is that the workflow step also removes the assignee, so I've been trying to grab it from a user field called "Last Developer". When I use this field, I'm getting a null user even when I re-index the issue beforehand. The script to set this custom field is a predefined Scriptrunner script.
When I use both the "Last Developer" custom field, as well as the assignee (I tried changing the order around). I'm logging that the watcher is removed, but the previous assignee is still a watcher at the end of the transition.
Am I missing something? Is there a particular step in the workflow post functions that I need to have this script in? I have admin rights in the project so the manage watchers permission shouldn't be the problem.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.customfieldvalue.CustomFieldValue import com.atlassian.jira.issue.index.IssueIndexingService import com.atlassian.jira.util.ImportUtils import com.atlassian.sal.api.user.UserManager //reindexes issue prior to clearing watchers as otherwise the custom field is not persisted to DB def indexManager = ComponentAccessor.getComponent(IssueIndexingService) boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); indexManager.reIndex(issue) ImportUtils.setIndexIssues(wasIndexing); //sets managers def watcherManager = ComponentAccessor.getWatcherManager() def issueManager = ComponentAccessor.getIssueManager() def customFieldManager = ComponentAccessor.getCustomFieldManager() def userManager = ComponentAccessor.getUserManager() //grabs the developer object and user def getLastDevObj = customFieldManager.getCustomFieldObjectByName("Last Developer") def lastDevUser = userManager.getUserByName(issue.getCustomFieldValue(getLastDevObj).toString()) //clears the watcher watcherManager.stopWatching(lastDevUser,issue)
I think you are probably not missing anything, except that there is a JIRA event listener built-in which always adds the current user as a watcher. That can be disabled per user, but only for all issues.
The order that listeners fire in is non-deterministic (I think), so chances are the JIRA one is coming after your one. Actually this is a workflow function, so definitely after.
If that's not the problem it might be to do with the types of user... is this JIRA 6.x?
Thank you for getting back to me. We're currently running JIRA 7.1.4. I've tried adding the workflow function after the Generic Event in the workflow, but I'm assuming that the listener is still picking up the watcher assignment after the transition.
Is there any way we can work around this without making huge changes? If not then that's fine, but I don't know of another way to manage watchers in the workflow step.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.