Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pull people from groups and add them to a custom field?

Ian Johnsen March 1, 2019

How do I pull people from groups and add them to a custom field?

Example:

 

Group: team_support

team_support = Troy, Ian, Gaven

Multi User Custom Field: "Support Members"

team_support -> "Support Members"

"Support Members" = Troy, Ian, Gaven

 

Workflow Post Function?

Add on?

 

Thanks!
Ian

2 answers

0 votes
Ian Johnsen March 1, 2019

@Alex Christensen Yeah we have both ScriptRunner and Automation for Jira. If members change in groups, no problem. Just need jira to pickup new group members with new tickets, not existing or constant update (although would be nice and more automated).

What would you suggest we do here? Can you break it down for me? :D

For more context: we are trying to automate approvals in Service Desk by pulling people from AD groups. Accomplishing this would be a HUGE game changer for us.

 

Thanks,

Ian

0 votes
Alex Christensen
Community Champion
March 1, 2019

This is definitely not possible out of the box in Jira. A few options you might want to explore:

  • Do you have ScriptRunner? You could probably create a script post-function which adds all users from a single user group to a multi-user picker field.
  • If you're adding the same users every time, you could also use a post-function to update the value of that field to the same thing every time. The only thing this wouldn't cover is if the membership of the "team_support" user group changed.
  • You could do the same thing as the last bullet point, but using Automation for Jira.
Alex Christensen
Community Champion
March 4, 2019

@Ian Johnsen for a ScriptRunner workflow post-function, try something like this. I haven't tested this code, but it's a start for you.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

// get group manager and user group
def groupManager = ComponentAccessor.getGroupManager()
def groupUsers = groupManager.getUsersInGroup("team_support", false) // false is used to not include inactive users

// get custom field for multi-user custom field
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def supportMembersField = customFieldManager.getCustomFieldObjectByName("Support Members")

// set custom field value
issue.setCustomFieldValue(supportMembersField, groupUsers)

// update issue with changes
def issueManager = ComponentAccessor.getIssueManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

 I also found a few related examples for you in case you want to look at those, too:

Suggest an answer

Log in or Sign up to answer