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 Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

88 views 0 5
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