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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage
Highlighted

(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
Community showcase
Published in Jira Service Management

Announcing Jira Service Management!

Hello there Cloud Community members! Today, we’re thrilled to announce Jira Service Management, the next generation of Jira Service Desk. Jira Service Management touts advancements in IT service ...

1,653 views 23 33
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you