You can try:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.comments.CommentManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.user.util.UserManager import com.atlassian.crowd.embedded.api.User // added line no.1 import com.atlassian.jira.component.ComponentAccessor // added line no.2 userManager = (UserManager) ComponentAccessor.getUserManager() MutableIssue issue = issue User usera = userManager.getUser('my_user_name'); issue.setAssignee(usera);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Posting code formatted as code in a readable way (CR/LF...) will increase your chances of getting help...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Correct way as of 2020 is using
issue.setAssignee(user)
issueMgr.updateIssue(currUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
issue.store should not be used in scripts at all, according to message it shows when you put in console:
Whole script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
UserManager userMgr = ComponentAccessor.getUserManager()
IssueManager issueMgr = ComponentAccessor.getIssueManager()
ApplicationUser currUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ApplicationUser newAssignee = userMgr.getUserByName("username")
issue.setAssignee(newAssignee)
issueMgr.updateIssue(currUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
API seems to have changed. Nothing on the page worked for me. But this works:
issue.setAssignee(ComponentAccessor.userManager.getUser("someuser"))
issue.store()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
According to previous discussion on this in here. Mizan suggested to try use the following instead
ComponentManager.getInstance().getUserUtil().getUser(
'ngs'
)
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.