I'm using Script Runner to assign issues in bulk. With my script it assignes the issue to the user, but in the issue navigator is still shows as Unassigned. What piece am I missing?
import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.Permissions import com.atlassian.jira.event.type.EventDispatchOption //Examples, 8 is my subtask issue type id. Will be different for others updateAssignee("PRJ-1483", "user1") //Method to do all the work def updateAssignee(parentId, userName) { def issue = ComponentManager.getInstance().getIssueManager().getIssueObject(parentId) def userManager = ComponentAccessor.getUserManager() def user = userManager.getUserObject(userName) issue.setAssignee(user) //Update the issue ComponentManager.getInstance().getIssueManager().updateIssue(ComponentManager.getInstance().jiraAuthenticationContext?.user, issue, EventDispatchOption.DO_NOT_DISPATCH, false) }
Community moderators have prevented the ability to post new answers.
I found that all I needed to do was use the IndexManager to have the issue re-index after I updated it.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.Permissions import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.util.ImportUtils //Examples, 8 is my subtask issue type id. Will be different for others updateAssignee("PRJ-1485", "user1") //Method to do all the work def updateAssignee(parentId, userName) { def issue = ComponentManager.getInstance().getIssueManager().getIssueObject(parentId) def userManager = ComponentAccessor.getUserManager() def user = userManager.getUserObject(userName) issue.setAssignee(user) //Update the issue ComponentManager.getInstance().getIssueManager().updateIssue(ComponentManager.getInstance().jiraAuthenticationContext?.user, issue, EventDispatchOption.DO_NOT_DISPATCH, false) ComponentManager.getInstance().getIndexManager().reIndex(issue); }
I'm currently on 5.1.3 and the manual reindex is not necessary (anymore?).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Isn't re-index is always needed for that issue once you update it? If you are using in post functions, I guess it is not needed as the it itself includes a re-index.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm using it in an EventListener (ISSUE_COMMENTED_ID).
The Javadoc on this method says:
This method will store the provided issue to the JIRA datastore. The issue will be saved and re-indexed.
But maybe that's wrong and my comment event triggered the re-index.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your script is not calling anything that would re-index the issue after your changes.
To test that guess, edit one of the affected issues and then try the issue navigator again. Your edit should trigger a re-index, which should fix the problem with that issue, if I am right.
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.