jira groovy issue assigned problem

 

Hello

Issue is getting assigned to number (Ex: 13329) instead of user. Here is my script

How can I get it assigned to user instead of number.

(Also any better way to save I see warning symbol)

Please let me know.


Thanks

Abe

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import org.apache.log4j.Category
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.user.ApplicationUser

def log = Logger.getLogger("com.sam.parallel")
log.setLevel(Level.DEBUG) 
//Issue issue = issue
def issueManager = ComponentAccessor.getIssueManager();
Issue issue = issueManager.getIssueObject("SIG-22" )
Project project = issue.getProjectObject()
//log.debug(project.getName())
UserManager userManager = ComponentManager.getComponentInstanceOfType(UserManager.class) as UserManager
def currentAssignee = issue.getAssignee()
ComponentManager componentManager = ComponentManager.getInstance()
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
// Get Parallel Approver Project Role
ProjectRole approverProjectRole = projectRoleManager.getProjectRole("Parallel Approvers")
ProjectRoleActors myAppro = projectRoleManager.getProjectRoleActors(approverProjectRole, issue.projectObject)
Set users = myAppro.getUsers()

Collection alist = new ArrayList()
users.each {
    alist.add(it.getId())    
}
Collections.shuffle(alist)
// Assign issue to first user after shuffle
log.debug( alist.get(0).toString() )
issue.setAssigneeId(  alist.get(0).toString()  )
issue.store()


1 answer

ok found it needed to put key instead of id.

users.each {
alist.add(it.getKey())
}

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

674 views 4 15
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot