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

This widget could not be displayed.

ok found it needed to put key instead of id.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked yesterday in Data Center

Hi! I'm Cameron Deatsch, enterprise enthusiast and Head of Server at Atlassian. AMA!

Hey team! I'm Cameron Deatsch, Head of Server at Atlassian. At our European Summit just a few weeks ago, I spoke about the latest regarding our Server and Data center products and o...

12,952 views 2 4
View question

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