Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,488
Community Members
 
Community Events
176
Community Groups

(Script Runner) Assign user to issue

Edited

Dear Community,

I want to assign an user from a group to an issue via post-function. In order to to do this, I wrote the following script:

// Component Accessor 
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def projectManager = ComponentAccessor.getComponent(ProjectManager);
def groupManager = ComponentAccessor.getGroupManager()
def issueService = ComponentAccessor.getIssueService()

// this statement is not used in the actual workflow, but in the console
Issue issue = ComponentAccessor.getIssueManager().getIssueObject('issue name')


// User Group Getter
CustomField groupField = customFieldManager.getCustomFieldObject('customfield_id')
def groupFieldVal = (List<Group>)issue.getCustomFieldValue(groupField)
String getGroupName(List<Group> pickertToIterate) {
for(Group group: pickertToIterate) {
String groupName = group.getName()
return groupName
}
}
String groupName = getGroupName(groupFieldVal)


// Get User from Group

def usersInGroup = groupManager.getUsersInGroup(groupName)
def appliUser = usersInGroup[5].getName()


def userManager = ComponentAccessor.getUserManager()
def user = userManager.getUserByName("our admin")

// Assign User to Issue
def validateAssignResult = issueService.validateAssign(user, issue.id, appliUser)


issueService.assign(user, validateAssignResult)

In the Script Runner Console this works perfectly so far. However, when I set this up in the actual workflow as  post function of my test project, this isn't working anymore. Nothing happens, despite of no given errors. Any ideas why?

Nina

0 comments

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events